| 1 |
<?php if (!defined('WPO_VERSION')) die('No direct access allowed'); ?> |
| 2 |
<div class="wpo_section wpo_group"> |
| 3 |
<div id="wpo_settings_warnings"></div> |
| 4 |
<form> |
| 5 |
<h3><?php _e('JavaScript options', 'wp-optimize'); ?></h3> |
| 6 |
<div class="wpo-fieldgroup"> |
| 7 |
<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 _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 _e('Enable merging of JavaScript files', 'wp-optimize'); ?> |
| 27 |
<span tabindex="0" data-tooltip="<?php _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 _e('Contain each included file in its own block', 'wp-optimize'); ?> |
| 38 |
<em><?php _e('(enable if trying to isolate a JavaScript error introduced by minifying or merging)', 'wp-optimize'); ?></em> |
| 39 |
<span tabindex="0" data-tooltip="<?php esc_attr_e('When enabled, the content of each JavaScript file that is combined will be wrapped in its own "try / catch" statement. This means that if one file has an error, it should not impede execution of other, independent files.', 'wp-optimize'); ?>"><span class="dashicons dashicons-editor-help"></span> </span> |
| 40 |
</label> |
| 41 |
</fieldset> |
| 42 |
</div> |
| 43 |
<h3><?php _e('Exclude JavaScript from processing', 'wp-optimize'); ?></h3> |
| 44 |
<div class="wpo-fieldgroup"> |
| 45 |
<fieldset> |
| 46 |
<label for="exclude_js"> |
| 47 |
<?php _e('Any JavaScript files that match the paths below will be completely ignored', 'wp-optmize'); ?> |
| 48 |
<span tabindex="0" data-tooltip="<?php esc_attr_e('Use this if you are having issues with a certain JavaScript file.', 'wp-optmize'); ?> <?php esc_attr_e('Any file present here will be loaded normally by WordPress', 'wp-optimize');?>"><span class="dashicons dashicons-editor-help"></span></span> |
| 49 |
</label> |
| 50 |
<textarea |
| 51 |
name="exclude_js" |
| 52 |
rows="7" cols="50" |
| 53 |
id="exclude_js" |
| 54 |
class="large-text code" |
| 55 |
placeholder="<?php esc_attr_e('e.g.: /wp-includes/js/jquery/jquery.js', 'wp-optimize'); ?>" |
| 56 |
><?php echo esc_textarea($wpo_minify_options['exclude_js']);?></textarea> |
| 57 |
<br> |
| 58 |
<?php _e('Some files known for causing issues when combined / minified are excluded by default.', 'wp-optimize'); ?> <?php _e('You can see / edit them in the Advanced tab.', 'wp-optimize'); ?> |
| 59 |
</fieldset> |
| 60 |
</div> |
| 61 |
|
| 62 |
<h3><?php _e('Defer JavaScript', 'wp-optimize'); ?></h3> |
| 63 |
<div class="wpo-fieldgroup"> |
| 64 |
<fieldset class="async-js-manual-list"> |
| 65 |
<h4><label> |
| 66 |
<input |
| 67 |
name="enable_defer_js" |
| 68 |
type="radio" |
| 69 |
value="individual" |
| 70 |
<?php echo checked($wpo_minify_options['enable_defer_js'], 'individual'); ?> |
| 71 |
> |
| 72 |
<?php _e('Defer selected JavaScript files', 'wp-optimize'); ?> |
| 73 |
<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> |
| 74 |
</label> |
| 75 |
</h4> |
| 76 |
<div class="defer-js-settings"> |
| 77 |
<label for="async_js"> |
| 78 |
<?php _e('Any JavaScript files that match the paths below will be loaded asynchronously.', 'wp-optmize'); ?> |
| 79 |
<br/> |
| 80 |
<?php _e('Use this if you have a completely independent script or would like to exclude scripts from page speed tests (PageSpeed Insights, GTMetrix...)', 'wp-optmize'); ?> |
| 81 |
<span tabindex="0" data-tooltip="<?php esc_attr_e('Independent scripts are for example \'analytics\' or \'pixel\' scripts. They are not required for the website to work', 'wp-optimize');?>"><span class="dashicons dashicons-editor-help"></span></span> |
| 82 |
</label> |
| 83 |
<textarea |
| 84 |
name="async_js" |
| 85 |
rows="7" |
| 86 |
cols="50" |
| 87 |
id="async_js" |
| 88 |
class="large-text code" |
| 89 |
placeholder="<?php esc_attr_e('e.g.: /js/main.js', 'wp-optimize'); ?>" |
| 90 |
><?php echo esc_textarea($wpo_minify_options['async_js']); ?></textarea> |
| 91 |
</div> |
| 92 |
</fieldset> |
| 93 |
|
| 94 |
<fieldset> |
| 95 |
<h4> |
| 96 |
<label> |
| 97 |
<input |
| 98 |
name="enable_defer_js" |
| 99 |
type="radio" |
| 100 |
value="all" |
| 101 |
<?php echo checked($wpo_minify_options['enable_defer_js'], 'all'); ?> |
| 102 |
> |
| 103 |
<?php _e('Defer all the JavaScript files', 'wp-optimize'); ?> |
| 104 |
<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> |
| 105 |
</label> |
| 106 |
</h4> |
| 107 |
<div class="defer-js-settings"> |
| 108 |
<div class="notice notice-warning below-h2"> |
| 109 |
<p class="wpo_min-bold-green wpo_min-rowintro"> |
| 110 |
<?php _e('Some themes and plugins need render blocking scripts to work.', 'wp-optimize'); ?> <?php _e('Please check the browser console for any eventual JavaScript errors caused by deferring the scripts.', 'wp-optimize'); ?> |
| 111 |
</p> |
| 112 |
</div> |
| 113 |
<h4><?php _e('Defer method:', 'wp-optimize'); ?></h4> |
| 114 |
<label> |
| 115 |
<input |
| 116 |
name="defer_js_type" |
| 117 |
type="radio" |
| 118 |
value="defer" |
| 119 |
<?php echo checked($wpo_minify_options['defer_js_type'], 'defer'); ?> |
| 120 |
> |
| 121 |
<?php _e('Use the "defer" html attribute', 'wp-optimize'); ?> |
| 122 |
<span tabindex="0" data-tooltip="<?php esc_attr_e('Supported by all modern browsers.', 'wp-optimize');?>"><span class="dashicons dashicons-editor-help"></span></span> |
| 123 |
</label> |
| 124 |
<label> |
| 125 |
<input |
| 126 |
name="defer_js_type" |
| 127 |
type="radio" |
| 128 |
value="async_using_js" |
| 129 |
<?php echo checked($wpo_minify_options['defer_js_type'], 'async_using_js'); ?> |
| 130 |
> |
| 131 |
<?php _e('Defer using JavaScript', 'wp-optimize'); ?> |
| 132 |
<em><?php printf(__('(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>');?></em> |
| 133 |
</label> |
| 134 |
<label for="defer_jquery"> |
| 135 |
<input |
| 136 |
name="defer_jquery" |
| 137 |
type="checkbox" |
| 138 |
id="defer_jquery" |
| 139 |
value="1" |
| 140 |
<?php echo checked($wpo_minify_options['defer_jquery']); ?> |
| 141 |
> |
| 142 |
<?php _e('Defer jQuery', 'wp-optimize'); ?> <em><?php _e('(Note that as jQuery is a common dependency, it probably needs to be loaded synchronously).', 'wp-optimize'); ?></em> |
| 143 |
<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> |
| 144 |
</label> |
| 145 |
</div> |
| 146 |
</fieldset> |
| 147 |
</div> |
| 148 |
|
| 149 |
<p class="submit"> |
| 150 |
<input |
| 151 |
class="wp-optimize-save-minify-settings button button-primary" |
| 152 |
type="submit" |
| 153 |
value="<?php esc_attr_e('Save settings', 'wp-optimize'); ?>" |
| 154 |
> |
| 155 |
<img class="wpo_spinner" src="<?php echo esc_attr(admin_url('images/spinner-2x.gif')); ?>" alt="..."> |
| 156 |
<span class="save-done dashicons dashicons-yes display-none"></span> |
| 157 |
</p> |
| 158 |
</form> |
| 159 |
</div> |
| 160 |
|