PluginProbe
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN / 1.3.6
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN v1.3.6
1.3.6 1.3.5 1.3.4 1.3.3 1.3.2 1.3.1 1.3.0 1.2.4 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 All 32 releases
← All changes | includes/class-minifier.php +38 -0 1.3.0 → 1.3.6 View file →
@@ -75,8 +75,15 @@
75 75 add_filter( 'style_loader_src', array( __CLASS__, 'rewrite_style' ), 10, 2 );
76 76 }
77 77 if ( ! empty( $opts['minify_js'] ) ) {
78 78 add_filter( 'script_loader_src', array( __CLASS__, 'rewrite_script' ), 10, 2 );
79 + // The src rewrite above runs before any plugin's own
80 + // `script_loader_tag` filter can stamp data-no-minify /
81 + // data-no-optimize onto the tag, so the marker arrives too late
82 + // to prevent it. Priority 15: after third-party tag filters at
83 + // the default 10 have printed their markers, before our defer
84 + // (20) and delay (30) look at the tag. (#456)
85 + add_filter( 'script_loader_tag', array( Minify_Filters::class, 'restore_marked_script_src' ), 15, 3 );
79 86 }
80 87
81 88 // Phase 4.1a — filter-only "smarter minifier" features. Each is
82 89 // gated on its own toggle so users can enable any subset.
@@ -91,8 +98,14 @@
91 98 // Delay applies a transform that's mutually exclusive with
92 99 // plain defer — when both are on, delay wins (the bootstrap
93 100 // will re-attach as a regular <script> on interaction).
94 101 add_filter( 'script_loader_tag', array( Minify_Filters::class, 'delay_script_tag' ), 30, 3 );
102 + // Smart Delay: a delayed handle's before/after snippets park with
103 + // it, or the inline consumer would run at parse time against a
104 + // global that now arrives on first interaction. This filter fires
105 + // for every inline script WordPress prints, so it also covers
106 + // pages the cache buffer never filters.
107 + add_filter( 'wp_inline_script_attributes', array( Minify_Filters::class, 'park_smart_inline' ), 30, 2 );
95 108 add_action( 'wp_footer', array( Minify_Filters::class, 'print_delay_bootstrap' ), 1000 );
96 109 // script_loader_tag only fires for wp_enqueue_script()'d assets.
97 110 // Analytics / pixel / chat-widget tags printed straight into
98 111 // wp_head bypass it, and those are usually the heaviest scripts
@@ -105,8 +118,27 @@
105 118 // so the src sweep above never sees them; this one parks an
106 119 // inline body that names a known third-party host.
107 120 add_filter( 'xspeed_cache_final_html', array( Minify_Filters::class, 'delay_inline_snippets' ), 21 );
108 121 }
122 +
123 + // Everything above honors data-no-optimize / data-no-minify, but
124 + // only sees markers stamped before priority 30. Borlabs Cookie
125 + // stamps at 100, so its consent config was minified AND delayed
126 + // despite carrying both markers. Snapshot the tag before our
127 + // transforms (9) and hand the original back if a marker turns up
128 + // after them (1000, past Borlabs' own 100 and 999). Registered
129 + // whenever any of the three is on,
130 + // since each one is individually enough to damage a marked
131 + // script. (#469)
132 + if ( ! empty( $opts['minify_js'] ) || ! empty( $opts['defer_js'] ) || ! empty( $opts['delay_js'] ) ) {
133 + add_filter( 'script_loader_tag', array( Minify_Filters::class, 'snapshot_tag' ), 9, 3 );
134 + add_filter(
135 + 'script_loader_tag',
136 + array( Minify_Filters::class, 'revert_late_marked_tag' ),
137 + Minify_Filters::late_opt_out_priority(),
138 + 3
139 + );
140 + }
109 141 if ( ! empty( $opts['async_css'] ) ) {
110 142 add_filter( 'style_loader_tag', array( Minify_Filters::class, 'async_style_tag' ), 20, 2 );
111 143 // style_loader_tag only fires for wp_enqueue_style()'d sheets.
112 144 // Themes print Google/Bunny/Typekit font CSS as literal <link>
@@ -432,8 +464,14 @@
432 464 }
433 465 list( , $open, $body, $close ) = $parts;
434 466
435 467 if ( '' === trim( $body ) ) {
468 + return $block;
469 + }
470 +
471 + // The tag asked to be left alone (data-no-optimize / data-no-minify —
472 + // the convention consent managers print on their config scripts). (#456)
473 + if ( Minify_Filters::tag_opts_out( $open ) ) {
436 474 return $block;
437 475 }
438 476
439 477 // Refuse a body that is already structurally broken. balanced() only