Skip to main content
KadiCache
Browse 37 Docs Guides & Search

Per-Page Script Manager (Zero-Reload Drawer, Core Layout Guard, Guest Preview & AI MCP)

Open the Zero-Reload Shadow DOM Script Manager drawer from the Admin Bar to inspect and disable unused JS, CSS, and WP 6.5+ ES Modules with dynamic /uploads/ builder classification, Core Layout Guard, signed Guest Preview URLs, Pro RUCSS/LCP sync, and AI MCP control.

Optimization/ScriptManager/RuleStore.phpOptimization/ScriptManager/PageIdentity.phpOptimization/ScriptManager/AssetInspector.phpOptimization/ScriptManager/AssetEnforcer.phpOptimization/ScriptManager/ScriptManagerUi.php
Frontend Admin Bar -> Script Manager (Zero-Reload Aurora Light Drawer)
MODULE 18 · 2X RETINA
Zero-reload Shadow DOM slide-down drawer matching KadiCache Aurora UI with instant Left Rail source filtering, 36px dense rows, dynamic /uploads/ classification, and automatic Core Layout safety badges.1366×820 WebP
Quick Summary · 30-Second Operational SpecSource-Verified Guide
WP Admin Path
WP Admin -> KadiCache -> CSS & JavaScript -> Per-Page Script Manager (Admin Bar)
Expected Outcome
Zero-Reload Shadow DOM Drawer · Core Layout Guard · Signed Guest Preview · JS + CSS + ES Modules
Key Marker / Engine
AssetEnforcer.php | AssetInspector.php | PageIdentity.php | RuleStore.php | ScriptManagerUi.php
  • Opt-in with 0 ms overhead when disabled: clicking Script Manager in the WordPress Admin Bar opens a Zero-Reload Shadow DOM Slide-Down Drawer directly inside the live page (Aurora Light/Dark parity, Left Rail source navigator, and compact 36px rows for 90+ asset pages).
  • Works across every WordPress page type (Front Page, Blog Index, Singular Posts/Pages/Products/CPTs, WooCommerce Shop, Taxonomies, Author/Date, Search, 404, Paginated /page/N/, Virtual Routes, and Multilingual URLs) with dynamic /wp-content/uploads/ classification for Elementor, Divi, Bricks, Beaver Builder, Oxygen, Astra, Kadence, and active themes.
  • Protects layouts automatically with the Core Layout Guard (flags Theme CSS, stylesheets with >= 2 KB inline CSS, and handles with active dependents; skips critical handles during bulk group disables; removes Disable Group from Theme, WordPress Core, and Other Local Assets).
  • Ships Testing Mode + Signed 10-Minute Guest Preview URLs (?kadicache_sm_preview=...) so both AI MCP agents and incognito browsers can visually verify rules without admin login cookies, plus WP Admin 1-click Reset All Rules, Checkout/Builder shields, and instant ?kadicache_sm_off=1 recovery.

1. Enabling Script Manager & Opening the Zero-Reload Drawer#

  1. Go to WP Admin -> KadiCache -> CSS & JavaScript -> Per-Page Script Manager (Admin Bar) and turn on Enable Script Manager (optionally enable Admin-Only Testing Mode while configuring your first rules). If saved rules already exist in kadicache_script_manager, the WP Admin card displays them directly alongside a 1-click Reset All Rules button.
  2. Visit any public page on your site (Homepage, Product, Shop Archive, Category, Search, or even a 404 page).
  3. Click the Script Manager button in the top WordPress Admin Bar (showing isolated 18px live disabled-count and TEST badges across every theme, desktop/mobile, and LTR/RTL).
  4. Without reloading the page or wrapping PHP in ob_start(), KadiCache slides down a Shadow DOM (:host { all: initial; }) Aurora drawer populated by AssetInspector.php with 100% of Head and Footer scripts, stylesheets, and WP 6.5+ ES Modules. Use the Left Rail to isolate any plugin/theme in one click, sort by Heavy ↓ / A–Z, or collapse groups while scanning compact 36px rows (ON = loaded, OFF = disabled). You can also deep-link directly with ?kadicache_sm=1.
FIG 01Zero-reload Shadow DOM workspace with Left Rail source filter, compact 36px rows, Elementor /uploads/ grouping, and Core Layout guard badgesZoom 2x

2. Smart /wp-content/uploads/ Classification & Scopes#

Modern page builders and themes compile dynamic CSS under /wp-content/uploads/ rather than /wp-content/plugins/. AssetInspector.php automatically maps compiled upload directories (elementor, et-cache for Divi, bricks, bb-plugin, oxygen, breakdance, fusion-styles, uag-plugin, brizy, astra, kadence, generatepress, woodmart, flatsome, plus active plugin and parent/child theme slugs) to their real owner instead of hiding them in Other Local Assets.

Toggle any asset OFF to expand its inline rule controls and choose a scope:

ScopeWhen It MatchesCommon Example
Current URLExact canonical path (including paginated /page/N/ variant)Disable a heavy chart library on / only
Everywhere (with Exceptions)Entire site except listed URLs, Front Page, Blog Index, Post Types, Archives, or RegexDisable Contact Form 7 everywhere except /contact/
Post TypesSingular posts of selected post types (never bleeds onto archives)Disable table-of-contents script on product pages
Archives & Special PagesFront Page, Blog Index, Shop (post_type_archive:product), Taxonomies, Author, Date, Search, 404Disable slider CSS on all Category & Search pages
URL Pattern (Regex)Bounded ReDoS-safe regular expression (max 160 chars, max 20 rules)Target /courses/.* without listing each lesson

3. Universal Core Layout Guard, Dependency Warnings & Signed Guest Preview#

  • Universal Core Layout Guard: AssetInspector.php automatically marks an asset is_critical_layout: true (amber Core Layout badge) when it is active Theme CSS, carries >= 2 KB of attached inline CSS (such as Elementor Kit/Post CSS, Divi, Kadence, or WP global-styles), or has active dependents. Disabling a handle with inline code displays the exact KB of inline CSS/JS that will also be stripped, requires confirmation when Testing Mode is off, is skipped automatically during bulk Disable Group, and Disable Group is never shown on Theme, WordPress Core, or Other Local Assets.
  • Dependency Guard: Before disabling shared libraries like jquery-core or wc-add-to-cart, Script Manager lists every active handle on the page that depends on it and offers an optional Also disable dependents cascade toggle. By default, AssetEnforcer.php detaches the disabled handle from surviving dependents' $deps so dependents keep running.
  • Testing Mode + Signed 10-Minute Guest Preview (?kadicache_sm_preview=...): Rules apply only for logged-in administrators and requests carrying a stateless HMAC-signed preview token (PageIdentity::previewUrl()), valid for 10 minutes with strict DONOTCACHEPAGE, Cache-Control: private, no-store, X-Robots-Tag: noindex, nofollow, and X-KadiCache-SM-Preview: 1. Anonymous visitors and Pro Cloud stay 100% unaffected while you (in Incognito) or an AI agent visually verify the exact guest render before switching Testing Mode off.
  • Protected Handles & Builders: All kadicache*, kadicache-pro*, and admin-bar handles are locked. Script Manager automatically bypasses wp-admin, AJAX, REST, Cron, WP-CLI, AMP, and all major page builder editors (Elementor, Bricks, Divi, Oxygen, Beaver Builder, Brizy). WooCommerce Cart/Checkout/My Account pages are protected by default via Protect Checkout.
FIG 02Inline collapsible rule editor, Testing Mode warning banner, signed Guest Preview CTA, and live Admin Bar count/TEST badgesZoom 2x

4. Zero-Conflict Sync With Delay JS, Early Cache & Pro Cloud#

Because AssetEnforcer.php runs during WordPress enqueue/print hooks before KadiCache's HTML output buffers:

  • Disabled assets never enter CssOptimizer, JsOptimizer, DelayJsOptimizer, or Pro Cloud Browser Lab.
  • Saving a Current URL rule purges only that URL across FileCache, EarlyCache, Pro LearningRevision, Pro Local BrowserHintsStore, and Pro ImageQueue. Saving a broad rule uses the dedicated 'script_manager' purge reason so Pro Cloud RUCSS and Local LCP refresh automatically.

5. Controlling Script Manager via AI MCP (manage_script_manager)#

Claude, Cursor, Antigravity, and ChatGPT can audit and verify rules end-to-end through manage_script_manager and the safe-script-audit guided prompt:

JSONAI MCP Safe Audit, Signed Preview & Rollback Flow
// 1. Inspect every JS, CSS & ES Module on /shop/ (includes is_critical_layout & /uploads/ owner)
{ "tool": "manage_script_manager", "arguments": { "action": "inspect_url", "url": "/shop/" } }

// 2. Simulate candidate rules in memory (blocks HTTP errors, orphaned_dependents & critical_layout_disabled)
{ "tool": "manage_script_manager", "arguments": { "action": "simulate_rules", "rules": [{ "handle": "contact-form-7", "type": "js", "status": "disabled", "scope": "everywhere", "exceptions": { "urls": ["/contact/"] } }] } }

// 3. Apply in Testing Mode -> returns checkpoint_id AND signed 10-minute preview_url (?kadicache_sm_preview=...)
//    so the AI or owner can visually verify the live render without an admin login cookie!
{ "tool": "manage_script_manager", "arguments": { "action": "upsert_rules", "testing_mode": true, "rules": [...] } }

// 4. After visual verification on preview_url, publish to visitors:
{ "tool": "manage_script_manager", "arguments": { "action": "set_mode", "testing_mode": false } }

6. Troubleshooting & Emergency Recovery#

  • WP Admin 1-Click Reset: Open WP Admin -> KadiCache -> CSS & JavaScript -> Per-Page Script Manager to view active saved rules and click Reset All Rules directly from the card (even if Script Manager is currently toggled off).
  • Instant Per-Request Bypass: Append ?kadicache_sm_off=1 to any URL while logged in as an administrator to load the page with all Script Manager rules disabled.
  • Global wp-config.php Kill Switch: Add define('KADICACHE_DISABLE_SCRIPT_MANAGER', true); to disable all Script Manager dequeuing site-wide immediately.
  • In-Drawer / MCP Reset: Open Script Manager -> Global Rules -> Reset All Rules (or call rollback_checkpoint via MCP) to clear rules and purge cache cleanly.

Frequently Asked Operational Questions

Can an AI MCP agent or Incognito browser preview Testing Mode rules without an admin login cookie?
Yes. Whenever Testing Mode is enabled, KadiCache generates a stateless 10-minute HMAC-signed Guest Preview URL (?kadicache_sm_preview=<expires>.<sig>) inside the Script Manager drawer, WP Admin card, and MCP manage_script_manager responses. The preview response sends DONOTCACHEPAGE, Cache-Control: private, no-store, and X-Robots-Tag: noindex, nofollow without granting any admin privileges or affecting live visitors.
Can anonymous visitors or search engines access ?kadicache_sm=1?
No. ScriptManagerUi verifies is_user_logged_in() and current_user_can('manage_options'). Guests hitting ?kadicache_sm=1 simply see the normal page with zero asset data disclosed, and TargetPath::PROTECTED_QUERY prevents ?kadicache_sm=1, ?kadicache_sm_off=1, and ?kadicache_sm_preview from ever being cached.
What happens to assets enqueued late in the page footer by shortcodes or blocks?
Script Manager hooks both wp_print_scripts/wp_print_styles (Head) and wp_print_footer_scripts (Footer) plus script_loader_src, style_loader_src, and script_module_loader_src so late-enqueued shortcode and block assets are both detected and cleanly dequeued.
Does KadiCache Script Manager support WordPress 6.5+ Interactivity API ES Modules?
Yes. AssetInspector reads wp_script_modules() alongside $wp_scripts and $wp_styles, and AssetEnforcer uses wp_dequeue_script_module() and script_module_loader_src to disable ES Modules cleanly.
How does Script Manager interact with KadiCache Pro Cloud Remove Unused CSS?
Disabled stylesheets never reach the rendered HTML or Pro Cloud Browser Lab, making RUCSS even faster. Whenever you save or remove a rule, KadiCache fires kadicache_script_manager_changed and purges with the dedicated script_manager reason so Pro RUCSS, Layout Stability, and Local LCP refresh automatically.
Gergis — Lead Systems & Cache Architect
Principal WordPress & Cloud Edge Architect
E-E-A-T Source Verified

Creator of KadiCache’s Early PHP Drop-In, 7-Driver Object Cache Engine, Cloud Remove Unused CSS, and Zero-CLS Lazy Render pipeline.

apps/wordpress-plugin/src/Optimization/ScriptManager/RuleStore.phpapps/wordpress-plugin/src/Optimization/ScriptManager/PageIdentity.phpapps/wordpress-plugin/src/Optimization/ScriptManager/AssetInspector.phpapps/wordpress-plugin/src/Optimization/ScriptManager/AssetEnforcer.phpapps/wordpress-plugin/src/Optimization/ScriptManager/ScriptManagerUi.php
Was this engineering guide helpful?