| @@ -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 { |
| @@ -75,9 +76,9 @@ | ||
| 75 | 76 | 'delay_js' => array( |
| 76 | 77 | 'type' => 'bool', |
| 77 | 78 | 'default' => false, |
| 78 | 79 | 'label' => __( 'Delay JavaScript Until Interaction', 'xspeed' ), |
| 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.', '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, |
| @@ -94,9 +95,9 @@ | ||
| 94 | 95 | 'type' => 'list', |
| 95 | 96 | 'default' => array( 'jquery-core', 'jquery-migrate' ), |
| 96 | 97 | 'item_type' => 'string', |
| 97 | 98 | 'label' => __( 'Defer / Delay Exclusions', 'xspeed' ), |
| 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.', '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( |
| @@ -109,9 +110,22 @@ | ||
| 109 | 110 | 'type' => 'list', |
| 110 | 111 | 'default' => array(), |
| 111 | 112 | 'item_type' => 'string', |
| 112 | 113 | 'label' => __( 'Delay Only These Scripts', 'xspeed' ), |
| 113 | - '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. One per line.', '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 | + ), | |
| 121 | + 'dependsOn' => array( 'field' => 'delay_js' ), | |
| 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' ), | |
| 114 | 128 | 'dependsOn' => array( 'field' => 'delay_js' ), |
| 115 | 129 | ), |
| 116 | 130 | 'delay_js_timeout' => array( |
| 117 | 131 | 'type' => 'int', |