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/modules/Minify/MinifyModule.php +59 -27 1.2.4 → 1.3.6 View file →
@@ -19,8 +19,9 @@
19 19
20 20 defined( 'ABSPATH' ) || exit;
21 21
22 22 use XSpeed\Minifier as LegacyMinifier;
23 +use XSpeed\Minify_Filters;
23 24 use XSpeed\Module;
24 25 use XSpeed\Settings_Manager;
25 26
26 27 final class MinifyModule extends Module {
@@ -30,12 +31,12 @@
30 31 public const VERSION = '1.2.0';
31 32
32 33 public function ui_metadata(): array {
33 34 return array(
34 - 'label' => 'CSS & JavaScript',
35 - 'tab_label' => 'Minify', // its own tab on the CSS & JavaScript page
35 + 'label' => __( 'CSS & JavaScript', 'xspeed' ),
36 + 'tab_label' => __( 'Minify', 'xspeed' ), // its own tab on the CSS & JavaScript page
36 37 'icon' => 'Wand2',
37 - 'description' => 'Strip whitespace and rewrite enqueued CSS / JS.',
38 + 'description' => __( 'Strip whitespace and rewrite enqueued CSS / JS.', 'xspeed' ),
38 39 // Host page: Minify (this module) / Critical CSS (Pro) / Unused
39 40 // CSS (Pro) as tabs — the three CSS/JS optimizations live on one
40 41 // page instead of three sidebar rows (FBS-83633).
41 42 'custom_panel' => 'CssJsPanel',
@@ -46,57 +47,57 @@
46 47 return array(
47 48 'minify_html' => array(
48 49 'type' => 'bool',
49 50 'default' => false,
50 - 'label' => 'Minify HTML',
51 + 'label' => __( 'Minify HTML', 'xspeed' ),
51 52 // Names the logged-out caveat up front: minification runs on the
52 53 // request that WRITES a cache entry, and should_cache() refuses
53 54 // logged-in requests — so "view source while logged in" shows
54 55 // un-minified HTML and reads as the feature being broken. (#2)
55 - 'description' => 'Strip whitespace and comments from HTML output, including inline <style> and <script> blocks. Safe on most themes. Applies to cached (logged-out) responses — view the page in a private window to see the result.',
56 + 'description' => __( 'Strip whitespace and comments from HTML output, including inline <style> and <script> blocks. Safe on most themes. Applies to cached (logged-out) responses — view the page in a private window to see the result.', 'xspeed' ),
56 57 ),
57 58 'minify_css' => array(
58 59 'type' => 'bool',
59 60 'default' => false,
60 - 'label' => 'Minify CSS',
61 - 'description' => 'Compress and rewrite enqueued local stylesheets. External CSS is left untouched.',
61 + 'label' => __( 'Minify CSS', 'xspeed' ),
62 + 'description' => __( 'Compress and rewrite enqueued local stylesheets. External CSS is left untouched.', 'xspeed' ),
62 63 ),
63 64 'minify_js' => array(
64 65 'type' => 'bool',
65 66 'default' => false,
66 - 'label' => 'Minify JavaScript',
67 - 'description' => 'Compress enqueued local scripts. Disable if you hit script-loading conflicts on the frontend.',
67 + 'label' => __( 'Minify JavaScript', 'xspeed' ),
68 + 'description' => __( 'Compress enqueued local scripts. Disable if you hit script-loading conflicts on the frontend.', 'xspeed' ),
68 69 ),
69 70 'defer_js' => array(
70 71 'type' => 'bool',
71 72 'default' => false,
72 - 'label' => 'Defer JavaScript',
73 - 'description' => 'Add defer="defer" to enqueued script tags so they execute after HTML parsing. jQuery + its hard dependencies are skipped automatically.',
73 + 'label' => __( 'Defer JavaScript', 'xspeed' ),
74 + 'description' => __( 'Add defer="defer" to enqueued script tags so they execute after HTML parsing. jQuery + its hard dependencies are skipped automatically.', 'xspeed' ),
74 75 ),
75 76 'delay_js' => array(
76 77 'type' => 'bool',
77 78 'default' => false,
78 - 'label' => 'Delay JavaScript Until Interaction',
79 - 'description' => 'Postpone script loading until the visitor scrolls, moves the mouse, taps, or presses a key. Drastically improves first paint on script-heavy pages; can break above-the-fold scripted UI — test before leaving on.',
79 + 'label' => __( 'Delay JavaScript Until Interaction', 'xspeed' ),
80 + 'description' => __( 'Postpone script loading until the visitor scrolls, moves the mouse, taps, or presses a key. Drastically improves first paint on script-heavy pages; can break above-the-fold scripted UI — test before leaving on. Cookie-consent banners (CookieYes, Complianz, Cookiebot, NotificationX, Cookie Notice, Borlabs, Real Cookie Banner and others) are not delayed, so the visitor is still asked before anything else runs. To delay one on purpose, name it in Delay Only These Scripts.', 'xspeed' ),
80 81 ),
81 82 'async_css' => array(
82 83 'type' => 'bool',
83 84 'default' => false,
84 - 'label' => 'Load CSS Asynchronously',
85 - 'description' => 'Rewrite stylesheet link tags to load non-blocking via the print-then-all pattern. Pairs well with critical-CSS workflows; can cause a flash of unstyled content if the theme has no critical CSS.',
85 + 'label' => __( 'Load CSS Asynchronously', 'xspeed' ),
86 + 'description' => __( 'Rewrite stylesheet link tags to load non-blocking via the print-then-all pattern. Pairs well with critical-CSS workflows; can cause a flash of unstyled content if the theme has no critical CSS.', 'xspeed' ),
86 87 ),
87 88 'remove_query_strings' => array(
88 89 'type' => 'bool',
89 90 'default' => false,
90 - 'label' => 'Remove Asset Query Strings',
91 - 'description' => 'Strip ?ver=X.Y from enqueued CSS / JS URLs. Some CDN caches and proxies cache better when query strings are absent.',
91 + 'label' => __( 'Remove Asset Query Strings', 'xspeed' ),
92 + 'description' => __( 'Strip ?ver=X.Y from enqueued CSS / JS URLs. Some CDN caches and proxies cache better when query strings are absent. Files under wp-content/uploads keep their version — page builders and consent plugins rewrite generated CSS there in place, and ?ver is what tells browsers to refetch it. Plugin, theme and core assets are still stripped: with Browser Cache on, an update reaches returning visitors only when their browser cache expires.', 'xspeed' ),
92 93 ),
93 94 'defer_js_excluded' => array(
94 95 'type' => 'list',
95 96 'default' => array( 'jquery-core', 'jquery-migrate' ),
96 97 'item_type' => 'string',
97 - 'label' => 'Defer / Delay Exclusions',
98 - 'description' => 'Script handles OR URL substrings that skip defer + delay. Defaults exclude jQuery (most themes depend on it being available synchronously). One per line.',
98 + 'label' => __( 'Defer / Delay Exclusions', 'xspeed' ),
99 + 'description' => __( 'Script handles OR URL substrings that skip defer + delay. Defaults exclude jQuery (most themes depend on it being available synchronously). Cookie-consent banners are skipped without being listed here. An entry here also wins over the same script in Delay Only These Scripts. One per line.', 'xspeed' ),
99 100 // Only relevant once defer OR delay is on — the exclusion list
100 101 // governs both. Uses the `any` (OR) dependency form. (FBS-82227)
101 102 'dependsOn' => array(
102 103 'any' => array(
@@ -108,33 +109,46 @@
108 109 'delay_js_targets' => array(
109 110 'type' => 'list',
110 111 'default' => array(),
111 112 'item_type' => 'string',
112 - 'label' => 'Delay Only These Scripts',
113 - 'description' => 'Script handles OR URL substrings. When non-empty, ONLY matching scripts are delayed — everything else loads normally. Leave empty to delay all scripts (minus the exclusions above). Ideal for postponing one heavy third-party embed without touching the rest of the page. Handles are the more reliable selector — a URL substring has to match the script\'s original URL, and minification rewrites that to a hashed cache path. One per line.',
113 + 'label' => __( 'Delay Only These Scripts', 'xspeed' ),
114 + 'description' => __( 'Script handles OR URL substrings. When non-empty, matching scripts are delayed, plus the known third-party tags xSpeed recognises on its own (analytics, tag managers, chat widgets, review embeds, error trackers) — so a heavy vendor script is postponed even when it is not listed here. Leave empty to delay all scripts (minus the exclusions above). Handles are the more reliable selector — a URL substring has to match the script\'s original URL, and minification rewrites that to a hashed cache path. Cookie-consent banners are only delayed when an entry names one, for example notificationx or cookiebot. A broad entry such as /plugins/ does not delay them. One per line.', 'xspeed' ),
115 + 'info_title' => __( 'Consent banners and Delay JS', 'xspeed' ),
116 + 'info' => sprintf(
117 + /* translators: %s: comma-separated list of consent plugins, each followed by the word to type in parentheses. */
118 + __( 'These consent banners load straight away, even with Delay JS on: %s. To delay one on purpose, add the word in parentheses, or the script handle, to this list. An entry that only matches part of the address, such as /plugins/ or .js, never delays a banner, and an entry in Defer / Delay Exclusions always wins.', 'xspeed' ),
119 + implode( ', ', Minify_Filters::consent_manager_labels() )
120 + ),
114 121 'dependsOn' => array( 'field' => 'delay_js' ),
115 122 ),
123 + 'delay_js_smart' => array(
124 + 'type' => 'bool',
125 + 'default' => false,
126 + 'label' => __( 'Smart Delay (Carry Inline Snippets)', 'xspeed' ),
127 + 'description' => __( 'Normally a script is left running at load when inline code on the page depends on it — on builder pages that keeps most scripts eager even with Delay JavaScript on. Smart Delay postpones those scripts anyway and parks their inline snippets with them; everything replays in page order on the first interaction. The most aggressive setting on this page: test menus, sliders, and toggles before leaving it on. Exclusions above still win, and consent banners still run first.', 'xspeed' ),
128 + 'dependsOn' => array( 'field' => 'delay_js' ),
129 + ),
116 130 'delay_js_timeout' => array(
117 131 'type' => 'int',
118 132 'default' => 8000,
119 133 'min' => 0,
120 134 'max' => 60000,
121 - 'label' => 'Delay Failsafe Timeout (ms)',
135 + 'label' => __( 'Delay Failsafe Timeout (ms)', 'xspeed' ),
122 136 'unit' => 'ms',
123 - 'description' => 'Load delayed scripts automatically after this many milliseconds when the visitor never interacts. Set to 0 for interaction-only, with no timer: a timer that fires inside a lab tool\'s measurement window loads the "delayed" scripts anyway and inflates the reported TTI. Keep a non-zero value if a delayed script must eventually run for visitors who never scroll, tap, or type.',
137 + 'description' => __( 'Load delayed scripts automatically after this many milliseconds when the visitor never interacts. Set to 0 for interaction-only, with no timer: a timer that fires inside a lab tool\'s measurement window loads the "delayed" scripts anyway and inflates the reported TTI. Keep a non-zero value if a delayed script must eventually run for visitors who never scroll, tap, or type.', 'xspeed' ),
124 138 'dependsOn' => array( 'field' => 'delay_js' ),
125 139 ),
126 140 'combine_css' => array(
127 141 'type' => 'bool',
128 142 'default' => false,
129 - 'label' => 'Combine CSS Files',
130 - 'description' => 'Concatenate enqueued local stylesheets into a single file (with @import and url(…) paths resolved). External CSS is left alone. Pairs poorly with HTTP/2 push — only enable on HTTP/1.1 hosts.',
143 + 'label' => __( 'Combine CSS Files', 'xspeed' ),
144 + 'description' => __( 'Concatenate enqueued local stylesheets into a single file (with @import and url(…) paths resolved). External CSS is left alone. Pairs poorly with HTTP/2 push — only enable on HTTP/1.1 hosts.', 'xspeed' ),
131 145 ),
132 146 'combine_js' => array(
133 147 'type' => 'bool',
134 148 'default' => false,
135 - 'label' => 'Combine JavaScript Files',
136 - 'description' => 'Concatenate enqueued local scripts into a single file. External scripts + scripts marked async / deferred are left alone. Disable if you hit dependency-order issues; the combiner respects WordPress enqueue order but inline scripts attached via wp_add_inline_script can shift behavior.',
149 + 'label' => __( 'Combine JavaScript Files', 'xspeed' ),
150 + 'description' => __( 'Concatenate enqueued local scripts into a single file. External scripts + scripts marked async / deferred are left alone. Disable if you hit dependency-order issues; the combiner respects WordPress enqueue order but inline scripts attached via wp_add_inline_script can shift behavior.', 'xspeed' ),
137 151 ),
138 152 );
139 153 }
140 154
@@ -216,8 +230,26 @@
216 230 * 2. Instantiate the v1 Minifier engine; it now reads from
217 231 * Settings_Manager::get('minify') via its updated read path.
218 232 */
219 233 public function boot(): void {
234 + /*
235 + * Deferred to `init`: both calls below read this module's settings,
236 + * which builds settings_schema(), whose labels go through __().
237 + * boot() runs on `plugins_loaded`, before `after_setup_theme` — the
238 + * earliest point WordPress 6.7+ considers safe to translate — so doing
239 + * it here fires _load_textdomain_just_in_time on every request and
240 + * resolves those labels against an unloaded domain.
241 + *
242 + * Every filter LegacyMinifier registers fires after `init`, so running
243 + * one hook later is equivalent.
244 + */
245 + add_action( 'init', array( $this, 'boot_on_init' ) );
246 + }
247 +
248 + /**
249 + * The real boot body — see boot() for why it runs on `init`.
250 + */
251 + public function boot_on_init(): void {
220 252 $this->seed_from_legacy_if_needed();
221 253 new LegacyMinifier();
222 254 }
223 255