| @@ -1,131 +1,157 @@ | ||
| 1 | -<?php if (!defined('WPO_VERSION')) die('No direct access allowed'); ?> | |
| 1 | +<?php if (!defined('ABSPATH')) die('No direct access allowed'); ?> | |
| 2 | 2 | <div id='wpo_section_js' class="wpo_section wpo_group"> |
| 3 | 3 | <div id="wpo_settings_warnings"></div> |
| 4 | + <div class="notice notice-warning wpo-warning is-dismissible wpo_section_notice_js show-if-enabled" style="<?php echo $show_section_notice ? '' : 'display:none;'; ?>"> | |
| 5 | + <p> | |
| 6 | + <span class="dashicons dashicons-shield"></span> | |
| 7 | + <strong><?php esc_html_e('Enable merging of JavaScript files into one to reduce HTTP requests.', 'wp-optimize'); ?></strong><br> | |
| 8 | + <?php echo wp_kses_post($notice_text);?> | |
| 9 | + </p> | |
| 10 | + </div> | |
| 4 | 11 | <form> |
| 5 | - <h3><?php esc_html_e('JavaScript options', 'wp-optimize'); ?></h3> | |
| 6 | - <div class="wpo-fieldgroup"> | |
| 12 | + <h3 class="show-if-enabled"><?php esc_html_e('JavaScript options', 'wp-optimize'); ?></h3> | |
| 13 | + <div class="wpo-fieldgroup show-if-enabled"> | |
| 7 | 14 | <fieldset> |
| 8 | - <label for="enable_js_minification"> | |
| 9 | - <input | |
| 10 | - name="enable_js_minification" | |
| 11 | - type="checkbox" | |
| 12 | - id="enable_js_minification" | |
| 13 | - value="1" | |
| 14 | - <?php echo checked($wpo_minify_options['enable_js_minification']); ?> | |
| 15 | - > | |
| 16 | - <?php esc_html_e('Enable minification of JavaScript files', 'wp-optimize'); ?> | |
| 17 | - </label> | |
| 18 | - <label for="enable_merging_of_js"> | |
| 19 | - <input | |
| 20 | - name="enable_merging_of_js" | |
| 21 | - type="checkbox" | |
| 22 | - id="enable_merging_of_js" | |
| 23 | - value="1" | |
| 24 | - <?php echo checked($wpo_minify_options['enable_merging_of_js']); ?> | |
| 25 | - > | |
| 26 | - <?php esc_html_e('Enable merging of JavaScript files', 'wp-optimize'); ?> | |
| 27 | - <span tabindex="0" data-tooltip="<?php esc_attr_e('If some functionality is breaking on the frontend, disabling merging of JavaScript might fix the issues.', 'wp-optimize');?>"><span class="dashicons dashicons-editor-help"></span> </span> | |
| 28 | - </label> | |
| 29 | - <label for="enable_js_trycatch"> | |
| 30 | - <input | |
| 31 | - name="enable_js_trycatch" | |
| 32 | - type="checkbox" | |
| 33 | - id="enable_js_trycatch" | |
| 34 | - value="1" | |
| 35 | - <?php echo checked($wpo_minify_options['enable_js_trycatch']); ?> | |
| 36 | - > | |
| 37 | - <?php esc_html_e('Contain each included file in its own block', 'wp-optimize'); ?> | |
| 38 | - <em><?php esc_html_e('(enable if trying to isolate a JavaScript error introduced by minifying or merging)', 'wp-optimize'); ?></em> | |
| 39 | - <?php | |
| 40 | - $message = __('When enabled, the content of each JavaScript file that is combined will be wrapped in its own "try / catch" statement.', 'wp-optimize'); | |
| 41 | - $message .= ' '; | |
| 42 | - $message .= __('This means that if one file has an error, it should not impede execution of other, independent files.', 'wp-optimize'); | |
| 43 | - ?> | |
| 44 | - <span tabindex="0" data-tooltip="<?php echo esc_attr($message); ?>"><span class="dashicons dashicons-editor-help"></span> </span> | |
| 45 | - </label> | |
| 15 | + <div class="wpo-fieldgroup__subgroup"> | |
| 16 | + <label for="enable_js_minification"> | |
| 17 | + <input | |
| 18 | + name="enable_js_minification" | |
| 19 | + type="checkbox" | |
| 20 | + id="enable_js_minification" | |
| 21 | + value="1" | |
| 22 | + <?php checked($wpo_minify_options['enable_js_minification']); ?> | |
| 23 | + > | |
| 24 | + <?php esc_html_e('Enable minification of JavaScript files', 'wp-optimize'); ?> | |
| 25 | + </label> | |
| 26 | + </div> | |
| 27 | + <div class="wpo-fieldgroup__subgroup"> | |
| 28 | + <label for="enable_merging_of_js"> | |
| 29 | + <input | |
| 30 | + name="enable_merging_of_js" | |
| 31 | + type="checkbox" | |
| 32 | + id="enable_merging_of_js" | |
| 33 | + value="1" | |
| 34 | + <?php checked($wpo_minify_options['enable_merging_of_js']); ?> | |
| 35 | + > | |
| 36 | + <?php esc_html_e('Enable merging of JavaScript files', 'wp-optimize'); ?> | |
| 37 | + </label> | |
| 38 | + <span tabindex="0" class="wpo-tooltip" data-tooltip="<?php echo esc_attr($tooltip); ?>"><span class="dashicons dashicons-editor-help"></span> </span> | |
| 39 | + </div> | |
| 40 | + <div class="wpo-fieldgroup__subgroup"> | |
| 41 | + <label for="enable_js_trycatch"> | |
| 42 | + <input | |
| 43 | + name="enable_js_trycatch" | |
| 44 | + type="checkbox" | |
| 45 | + id="enable_js_trycatch" | |
| 46 | + value="1" | |
| 47 | + <?php checked($wpo_minify_options['enable_js_trycatch']); ?> | |
| 48 | + > | |
| 49 | + <?php esc_html_e('Contain each included file in its own block', 'wp-optimize'); ?> | |
| 50 | + <em><?php esc_html_e('(enable if trying to isolate a JavaScript error introduced by minifying or merging)', 'wp-optimize'); ?></em> | |
| 51 | + <?php | |
| 52 | + $message = __('When enabled, the content of each JavaScript file that is combined will be wrapped in its own "try / catch" statement.', 'wp-optimize'); | |
| 53 | + $message .= ' '; | |
| 54 | + $message .= __('This means that if one file has an error, it should not impede execution of other, independent files.', 'wp-optimize'); | |
| 55 | + ?> | |
| 56 | + </label> | |
| 57 | + <span tabindex="0" class="wpo-tooltip" data-tooltip="<?php echo esc_attr($message); ?>"><span class="dashicons dashicons-editor-help"></span> </span> | |
| 58 | + </div> | |
| 46 | 59 | </fieldset> |
| 47 | 60 | </div> |
| 48 | - <h3><?php esc_html_e('Exclude JavaScript from processing', 'wp-optimize'); ?></h3> | |
| 49 | - <div class="wpo-fieldgroup"> | |
| 61 | + | |
| 62 | + <?php do_action('wpo_after_minify_javascript_options'); ?> | |
| 63 | + | |
| 64 | + <h3 class="show-if-enabled"><?php esc_html_e('Exclude JavaScript from processing', 'wp-optimize'); ?></h3> | |
| 65 | + <div class="wpo-fieldgroup show-if-enabled"> | |
| 50 | 66 | <fieldset> |
| 51 | - <label for="exclude_js"> | |
| 52 | - <?php esc_html_e('Any JavaScript files that match the paths below will be completely ignored', 'wp-optimize'); ?> | |
| 53 | - <span tabindex="0" data-tooltip="<?php esc_attr_e('Use this if you are having issues with a certain JavaScript file.', 'wp-optimize'); ?> <?php esc_attr_e('Any file present here will be loaded normally by WordPress', 'wp-optimize');?>"><span class="dashicons dashicons-editor-help"></span></span> | |
| 54 | - </label> | |
| 55 | - <textarea | |
| 56 | - name="exclude_js" | |
| 57 | - rows="7" cols="50" | |
| 58 | - id="exclude_js" | |
| 59 | - class="large-text code" | |
| 60 | - placeholder="<?php esc_attr_e('e.g.: /wp-includes/js/jquery/jquery.js', 'wp-optimize'); ?>" | |
| 61 | - ><?php echo esc_textarea($wpo_minify_options['exclude_js']);?></textarea> | |
| 62 | - <br> | |
| 63 | - <?php esc_html_e('Some files known for causing issues when combined / minified are excluded by default.', 'wp-optimize'); ?> <?php esc_html_e('You can see / edit them in the Advanced tab.', 'wp-optimize'); ?> | |
| 67 | + <div class="wpo-fieldgroup__subgroup"> | |
| 68 | + <label for="exclude_js"> | |
| 69 | + <?php esc_html_e('Any JavaScript files that match the paths below will be completely ignored', 'wp-optimize'); ?> | |
| 70 | + </label> | |
| 71 | + <span tabindex="0" class="wpo-tooltip" data-tooltip="<?php esc_attr_e('Use this if you are having issues with a certain JavaScript file.', 'wp-optimize'); ?> <?php esc_attr_e('Any file present here will be loaded normally by WordPress', 'wp-optimize');?>"><span class="dashicons dashicons-editor-help"></span></span> | |
| 72 | + <textarea | |
| 73 | + name="exclude_js" | |
| 74 | + rows="7" cols="50" | |
| 75 | + id="exclude_js" | |
| 76 | + class="large-text code" | |
| 77 | + placeholder="<?php esc_attr_e('e.g.: /wp-includes/js/jquery/jquery.js', 'wp-optimize'); ?>" | |
| 78 | + ><?php echo esc_textarea($wpo_minify_options['exclude_js']);?></textarea> | |
| 79 | + <br> | |
| 80 | + <?php esc_html_e('Some files known for causing issues when combined / minified are excluded by default.', 'wp-optimize'); ?> <?php esc_html_e('You can see / edit them in the Advanced tab.', 'wp-optimize'); ?> | |
| 81 | + </div> | |
| 64 | 82 | </fieldset> |
| 65 | 83 | </div> |
| 66 | 84 | |
| 67 | - <h3><?php esc_html_e('Defer JavaScript', 'wp-optimize'); ?></h3> | |
| 68 | - <div class="wpo-fieldgroup"> | |
| 85 | + <h3 class="show-if-enabled"><?php esc_html_e('Defer JavaScript', 'wp-optimize'); ?></h3> | |
| 86 | + <div class="wpo-fieldgroup show-if-enabled"> | |
| 69 | 87 | <fieldset class="async-js-manual-list"> |
| 70 | - <h4><label> | |
| 71 | - <input | |
| 72 | - name="enable_defer_js" | |
| 73 | - type="radio" | |
| 74 | - value="individual" | |
| 75 | - <?php echo checked($wpo_minify_options['enable_defer_js'], 'individual'); ?> | |
| 76 | - > | |
| 77 | - <?php esc_html_e('Asynchronously load selected JavaScript files', 'wp-optimize'); ?> | |
| 78 | - <span tabindex="0" data-tooltip="<?php esc_attr_e('The files in the list will be loaded asynchronously, and will not be minified or merged.', 'wp-optimize');?>"><span class="dashicons dashicons-editor-help"></span></span> | |
| 79 | - </label> | |
| 80 | - </h4> | |
| 81 | - <div class="defer-js-settings"> | |
| 82 | - <label for="async_js"> | |
| 83 | - <?php esc_html_e('Any JavaScript files that match the paths below will be loaded asynchronously.', 'wp-optimize'); ?> | |
| 84 | - <br> | |
| 85 | - <?php esc_html_e('Use this if you have a completely independent script', 'wp-optimize'); ?> | |
| 86 | - <?php | |
| 87 | - $message = __('Independent scripts are for example \'analytics\' or \'pixel\' scripts.', 'wp-optimize'); | |
| 88 | - $message .= ' '; | |
| 89 | - $message .= __('They are not required for the website to work', 'wp-optimize'); | |
| 90 | - ?> | |
| 91 | - <span tabindex="0" data-tooltip="<?php echo esc_attr($message);?>"><span class="dashicons dashicons-editor-help"></span></span> | |
| 92 | - </label> | |
| 93 | - <textarea | |
| 94 | - name="async_js" | |
| 95 | - rows="7" | |
| 96 | - cols="50" | |
| 97 | - id="async_js" | |
| 98 | - class="large-text code" | |
| 99 | - placeholder="<?php esc_attr_e('e.g.: /js/main.js', 'wp-optimize'); ?>" | |
| 100 | - ><?php echo esc_textarea($wpo_minify_options['async_js']); ?></textarea> | |
| 101 | - <label for="exclude_js_from_page_speed_tools"> | |
| 88 | + <div class="wpo-fieldgroup__subgroup"> | |
| 89 | + <h4><label> | |
| 102 | 90 | <input |
| 103 | - name="exclude_js_from_page_speed_tools" | |
| 104 | - type="checkbox" | |
| 105 | - id="exclude_js_from_page_speed_tools" | |
| 106 | - value="1" | |
| 107 | - <?php echo checked($wpo_minify_options['exclude_js_from_page_speed_tools']); ?> | |
| 91 | + name="enable_defer_js" | |
| 92 | + type="radio" | |
| 93 | + value="individual" | |
| 94 | + <?php checked($wpo_minify_options['enable_defer_js'], 'individual'); ?> | |
| 108 | 95 | > |
| 109 | - <?php esc_html_e('Exclude scripts from page speed tests (PageSpeed Insights, GTMetrix...)', 'wp-optimize'); ?> | |
| 110 | - <span tabindex="0" data-tooltip="<?php esc_attr_e('Use this only for testing purpose to find out which scripts are slowing down your site.', 'wp-optimize');?>"><span class="dashicons dashicons-editor-help"></span></span> | |
| 96 | + <?php esc_html_e('Asynchronously load selected JavaScript files', 'wp-optimize'); ?> | |
| 111 | 97 | </label> |
| 98 | + <span tabindex="0" class="wpo-tooltip" data-tooltip="<?php esc_attr_e('The files in the list will be loaded asynchronously, and will not be minified or merged.', 'wp-optimize');?>"><span class="dashicons dashicons-editor-help"></span></span><br> | |
| 99 | + </h4> | |
| 112 | 100 | </div> |
| 101 | + <div class="defer-js-settings"> | |
| 102 | + <div class="wpo-fieldgroup__subgroup"> | |
| 103 | + <label for="async_js"> | |
| 104 | + <?php esc_html_e('Any JavaScript files that match the paths below will be loaded asynchronously.', 'wp-optimize'); ?> | |
| 105 | + <br> | |
| 106 | + <?php esc_html_e('Use this if you have a completely independent script', 'wp-optimize'); ?> | |
| 107 | + <?php | |
| 108 | + $message = __('Independent scripts are for example \'analytics\' or \'pixel\' scripts.', 'wp-optimize'); | |
| 109 | + $message .= ' '; | |
| 110 | + $message .= __('They are not required for the website to work', 'wp-optimize'); | |
| 111 | + ?> | |
| 112 | + </label> | |
| 113 | + <span tabindex="0" class="wpo-tooltip" data-tooltip="<?php echo esc_attr($message);?>"><span class="dashicons dashicons-editor-help"></span></span> | |
| 114 | + <textarea | |
| 115 | + name="async_js" | |
| 116 | + rows="7" | |
| 117 | + cols="50" | |
| 118 | + id="async_js" | |
| 119 | + class="large-text code" | |
| 120 | + placeholder="<?php esc_attr_e('e.g.: /js/main.js', 'wp-optimize'); ?>" | |
| 121 | + ><?php echo esc_textarea($wpo_minify_options['async_js']); ?></textarea> | |
| 122 | + </div> | |
| 123 | + <div class="wpo-fieldgroup__subgroup"> | |
| 124 | + <label for="exclude_js_from_page_speed_tools"> | |
| 125 | + <input | |
| 126 | + name="exclude_js_from_page_speed_tools" | |
| 127 | + type="checkbox" | |
| 128 | + id="exclude_js_from_page_speed_tools" | |
| 129 | + value="1" | |
| 130 | + <?php checked($wpo_minify_options['exclude_js_from_page_speed_tools']); ?> | |
| 131 | + > | |
| 132 | + <?php esc_html_e('Exclude scripts from page speed tests (PageSpeed Insights, GTMetrix...)', 'wp-optimize'); ?> | |
| 133 | + </label> | |
| 134 | + <span tabindex="0" class="wpo-tooltip" data-tooltip="<?php esc_attr_e('Use this only for testing purpose to find out which scripts are slowing down your site.', 'wp-optimize');?>"><span class="dashicons dashicons-editor-help"></span></span><br> | |
| 135 | + </div> | |
| 136 | + </div> | |
| 113 | 137 | </fieldset> |
| 114 | 138 | |
| 115 | 139 | <fieldset> |
| 116 | - <h4> | |
| 117 | - <label> | |
| 118 | - <input | |
| 119 | - name="enable_defer_js" | |
| 120 | - type="radio" | |
| 121 | - value="all" | |
| 122 | - <?php echo checked($wpo_minify_options['enable_defer_js'], 'all'); ?> | |
| 123 | - > | |
| 124 | - <?php esc_html_e('Defer all the JavaScript files', 'wp-optimize'); ?> | |
| 125 | - <span tabindex="0" data-tooltip="<?php esc_attr_e('All files - including the ones processed by WP-Optimize - will be deferred, except the ones in the exclusion list above.', 'wp-optimize');?>"><span class="dashicons dashicons-editor-help"></span></span> | |
| 126 | - </label> | |
| 127 | - </h4> | |
| 140 | + <div class="wpo-fieldgroup__subgroup"> | |
| 141 | + <h4> | |
| 142 | + <label> | |
| 143 | + <input | |
| 144 | + name="enable_defer_js" | |
| 145 | + type="radio" | |
| 146 | + value="all" | |
| 147 | + <?php checked($wpo_minify_options['enable_defer_js'], 'all'); ?> | |
| 148 | + > | |
| 149 | + <?php esc_html_e('Defer all the JavaScript files', 'wp-optimize'); ?> | |
| 150 | + </label> | |
| 151 | + <span tabindex="0" class="wpo-tooltip" data-tooltip="<?php esc_attr_e('All files - including the ones processed by WP-Optimize - will be deferred, except the ones in the exclusion list above.', 'wp-optimize');?>"><span class="dashicons dashicons-editor-help"></span></span> | |
| 152 | + </h4> | |
| 153 | + </div> | |
| 128 | 154 | <div class="defer-js-settings"> |
| 129 | 155 | <div class="notice notice-warning below-h2"> |
| 130 | 156 | <p class="wpo_min-bold-green wpo_min-rowintro"> |
| 131 | 157 | <?php esc_html_e('Some themes and plugins need render blocking scripts to work.', 'wp-optimize'); ?> <?php esc_html_e('Please check the browser console for any eventual JavaScript errors caused by deferring the scripts.', 'wp-optimize'); ?> |
| @@ -131,59 +157,119 @@ | ||
| 131 | 157 | <?php esc_html_e('Some themes and plugins need render blocking scripts to work.', 'wp-optimize'); ?> <?php esc_html_e('Please check the browser console for any eventual JavaScript errors caused by deferring the scripts.', 'wp-optimize'); ?> |
| 132 | 158 | </p> |
| 133 | 159 | </div> |
| 134 | 160 | <h4><?php esc_html_e('Defer method:', 'wp-optimize'); ?></h4> |
| 135 | - <label> | |
| 161 | + <div class="wpo-fieldgroup__subgroup"> | |
| 162 | + <label> | |
| 163 | + <input | |
| 164 | + name="defer_js_type" | |
| 165 | + type="radio" | |
| 166 | + value="defer" | |
| 167 | + <?php checked($wpo_minify_options['defer_js_type'], 'defer'); ?> | |
| 168 | + > | |
| 169 | + <?php esc_html_e('Use the "defer" html attribute', 'wp-optimize'); ?> | |
| 170 | + </label> | |
| 171 | + <span tabindex="0" class="wpo-tooltip" data-tooltip="<?php esc_attr_e('Supported by all modern browsers.', 'wp-optimize');?>"><span class="dashicons dashicons-editor-help"></span></span> | |
| 172 | + </div> | |
| 173 | + <div class="wpo-fieldgroup__subgroup"> | |
| 174 | + <label> | |
| 175 | + <input | |
| 176 | + name="defer_js_type" | |
| 177 | + type="radio" | |
| 178 | + value="async_using_js" | |
| 179 | + <?php checked($wpo_minify_options['defer_js_type'], 'async_using_js'); ?> | |
| 180 | + > | |
| 181 | + <?php esc_html_e('Defer using JavaScript', 'wp-optimize'); ?> | |
| 182 | + <em> | |
| 183 | + <?php | |
| 184 | + $message = '('; | |
| 185 | + $message .= esc_html__('Asynchronous loading.', 'wp-optimize'); | |
| 186 | + $message .= ' '; | |
| 187 | + // translators: %1$s is a opening anchor tag, %2$s is a closing anchor tag | |
| 188 | + $message .= sprintf(esc_html__('Use this method if you require support for %1$solder browsers%2$s.', 'wp-optimize'), '<a href="https://www.w3schools.com/tags/att_script_defer.asp" target="_blank">', '</a>'); | |
| 189 | + $message .= ')'; | |
| 190 | + echo wp_kses_post($message); | |
| 191 | + ?> | |
| 192 | + </em> | |
| 193 | + </label> | |
| 194 | + </div> | |
| 195 | + <div class="wpo-fieldgroup__subgroup"> | |
| 196 | + <label for="defer_jquery"> | |
| 197 | + <input | |
| 198 | + name="defer_jquery" | |
| 199 | + type="checkbox" | |
| 200 | + id="defer_jquery" | |
| 201 | + value="1" | |
| 202 | + <?php checked($wpo_minify_options['defer_jquery']); ?> | |
| 203 | + > | |
| 204 | + <?php esc_html_e('Defer jQuery', 'wp-optimize'); ?> <em><?php esc_html_e('(Note that as jQuery is a common dependency, it probably needs to be loaded synchronously).', 'wp-optimize'); ?></em> | |
| 205 | + </label> | |
| 206 | + <span tabindex="0" class="wpo-tooltip" data-tooltip="<?php esc_attr_e('Disable this setting if you have an error \'jQuery undefined\'.', 'wp-optimize');?>"><span class="dashicons dashicons-editor-help"></span></span> | |
| 207 | + </div> | |
| 208 | + </div> | |
| 209 | + </fieldset> | |
| 210 | + </div> | |
| 211 | + | |
| 212 | + <h3><?php esc_html_e('Delay JavaScript', 'wp-optimize'); ?></h3> | |
| 213 | + <div class="wpo-fieldgroup"> | |
| 214 | + <fieldset> | |
| 215 | + <div class="wpo-fieldgroup__subgroup"> | |
| 216 | + <h4><label> | |
| 136 | 217 | <input |
| 137 | - name="defer_js_type" | |
| 138 | - type="radio" | |
| 139 | - value="defer" | |
| 140 | - <?php echo checked($wpo_minify_options['defer_js_type'], 'defer'); ?> | |
| 218 | + name="enable_delay_js" | |
| 219 | + type="checkbox" | |
| 220 | + value="true" | |
| 221 | + <?php checked($wpo_minify_options['enable_delay_js'], true); ?> | |
| 141 | 222 | > |
| 142 | - <?php esc_html_e('Use the "defer" html attribute', 'wp-optimize'); ?> | |
| 143 | - <span tabindex="0" data-tooltip="<?php esc_attr_e('Supported by all modern browsers.', 'wp-optimize');?>"><span class="dashicons dashicons-editor-help"></span></span> | |
| 223 | + <?php esc_html_e('Delay JS', 'wp-optimize'); ?> | |
| 144 | 224 | </label> |
| 145 | - <label> | |
| 225 | + <span tabindex="0" class="wpo-tooltip" data-tooltip="<?php esc_attr_e('Delays JavaScript file loading until the user interacts with the page (e.g., mouse movement, scrolling, or touch), thereby improving page load performance', 'wp-optimize'); ?>"><span class="dashicons dashicons-editor-help"></span> </span> | |
| 226 | + </h4> | |
| 227 | + </div> | |
| 228 | + | |
| 229 | + <div class="wpo-fieldgroup__subgroup"> | |
| 230 | + <h4><label> | |
| 146 | 231 | <input |
| 147 | - name="defer_js_type" | |
| 148 | - type="radio" | |
| 149 | - value="async_using_js" | |
| 150 | - <?php echo checked($wpo_minify_options['defer_js_type'], 'async_using_js'); ?> | |
| 232 | + name="enable_preload_js" | |
| 233 | + type="checkbox" | |
| 234 | + value="true" | |
| 235 | + <?php checked($wpo_minify_options['enable_preload_js'], true); ?> | |
| 151 | 236 | > |
| 152 | - <?php esc_html_e('Defer using JavaScript', 'wp-optimize'); ?> | |
| 153 | - <em> | |
| 154 | - <?php | |
| 155 | - $message = '('; | |
| 156 | - $message .= esc_html__('Asynchronous loading.', 'wp-optimize'); | |
| 157 | - $message .= ' '; | |
| 158 | - $message .= sprintf(esc_html__('Use this method if you require support for %solder browsers%s.', 'wp-optimize'), '<a href="https://www.w3schools.com/tags/att_script_defer.asp" target="_blank">', '</a>'); | |
| 159 | - $message .= ')'; | |
| 160 | - echo strip_tags($message, '<a>'); | |
| 161 | - ?> | |
| 162 | - </em> | |
| 237 | + <?php esc_html_e('Preload JavaScript files', 'wp-optimize'); ?> | |
| 163 | 238 | </label> |
| 164 | - <label for="defer_jquery"> | |
| 165 | - <input | |
| 166 | - name="defer_jquery" | |
| 167 | - type="checkbox" | |
| 168 | - id="defer_jquery" | |
| 169 | - value="1" | |
| 170 | - <?php echo checked($wpo_minify_options['defer_jquery']); ?> | |
| 171 | - > | |
| 172 | - <?php esc_html_e('Defer jQuery', 'wp-optimize'); ?> <em><?php esc_html_e('(Note that as jQuery is a common dependency, it probably needs to be loaded synchronously).', 'wp-optimize'); ?></em> | |
| 173 | - <span tabindex="0" data-tooltip="<?php esc_attr_e('Disable this setting if you have an error \'jQuery undefined\'.', 'wp-optimize');?>"><span class="dashicons dashicons-editor-help"></span></span> | |
| 239 | + <span tabindex="0" class="wpo-tooltip" data-tooltip="<?php esc_attr_e('Preloads JavaScript files in parallel with other resources ahead of time, ensuring they are ready for faster execution without impacting the overall page load time', 'wp-optimize'); ?>"><span class="dashicons dashicons-editor-help"></span> </span> | |
| 240 | + </h4> | |
| 241 | + </div> | |
| 242 | + | |
| 243 | + <div class="wpo-fieldgroup__subgroup"> | |
| 244 | + <label for="exclude_delay_js"> | |
| 245 | + <?php esc_html_e('Any JavaScript files that match the paths below will be completely ignored.', 'wp-optimize'); ?> | |
| 246 | + <?php esc_html_e('It is also possible to exclude scripts by adding the "data-no-delay-js" attribute.', 'wp-optimize'); ?> | |
| 174 | 247 | </label> |
| 248 | + <span tabindex="0" class="wpo-tooltip" data-tooltip="<?php esc_attr_e('Use this if you are having issues with a specific JavaScript file.', 'wp-optimize'); ?> <?php esc_attr_e('Any file present here will be loaded normally by WordPress', 'wp-optimize');?>"><span class="dashicons dashicons-editor-help"></span></span> | |
| 249 | + | |
| 250 | + <textarea | |
| 251 | + name="exclude_delay_js" | |
| 252 | + rows="7" cols="50" | |
| 253 | + id="exclude_delay_js" | |
| 254 | + class="large-text code" | |
| 255 | + placeholder="<?php esc_attr_e('e.g.: /wp-includes/js/jquery/jquery.js', 'wp-optimize'); ?>" | |
| 256 | + ><?php echo esc_textarea($wpo_minify_options['exclude_delay_js']);?></textarea> | |
| 257 | + <span> | |
| 258 | + <?php | |
| 259 | + esc_html_e('Use the wildcard * to similar JavaScript files.', 'wp-optimize'); | |
| 260 | + echo ' '; | |
| 261 | + // translators: %1$s and %2$s are examples of path using the wildcards | |
| 262 | + printf(esc_html_x('e.g. %1$s or %2$s', '%s are examples of path using the wildcard *', 'wp-optimize'), '<code>/js/*</code>', '<code>/jquery*.js</code>'); | |
| 263 | + ?> | |
| 264 | + </span> | |
| 175 | 265 | </div> |
| 176 | 266 | </fieldset> |
| 177 | 267 | </div> |
| 178 | 268 | |
| 179 | - <p class="submit"> | |
| 180 | - <input | |
| 181 | - class="wp-optimize-save-minify-settings button button-primary" | |
| 182 | - type="submit" | |
| 183 | - value="<?php esc_attr_e('Save settings', 'wp-optimize'); ?>" | |
| 184 | - > | |
| 185 | - <img class="wpo_spinner" src="<?php echo esc_url(admin_url('images/spinner-2x.gif')); ?>" alt="..."> | |
| 269 | + <div class="wpo-save-btn-container"> | |
| 270 | + <input class="wp-optimize-save-minify-settings button button-primary" type="submit" value="<?php esc_attr_e('Save settings', 'wp-optimize'); ?>"> | |
| 271 | + <img class="wpo_spinner" src="<?php echo esc_url(admin_url('images/spinner-2x.gif')); // phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage -- N/A ?>" alt="..."> | |
| 186 | 272 | <span class="save-done dashicons dashicons-yes display-none"></span> |
| 187 | - </p> | |
| 273 | + </div> | |
| 188 | 274 | </form> |
| 189 | 275 | </div> |