Settings saved.

'; } // load settings from database $aj_enabled = (get_option('aj_enabled') == 1) ? array(true,'checked','') : array(false,'','style="display:none;"'); $aj_method = (get_option('aj_method') != 'async') ? 'defer' : 'async'; $aj_exclusions = get_option('aj_exclusions'); $autoptimize_enabled = (get_option('autoptimize_enabled') == 1) ? 'checked' : ''; ?>

Async Javascript Settings

Enable Async Javascript

When you enable Async Javascript, when a script is loaded via the 'wp_enqueue_script' method, this plugin will add a 'async' or 'defer' attribute.
This action helps to eliminate render-blocking JavaScript in above-the-fold content. This can also help to increase your pagespeed which in turn will assist in improving your page ranking.
There are several ways an external script can be executed:
  • If async is present: The script is executed asynchronously with the rest of the page (the script will be executed while the page continues the parsing)
  • If async is not present and defer is present: The script is executed when the page has finished parsing
  • If neither async or defer is present: The script is fetched and executed immediately, before the browser continues parsing the page
Note: There have been instances where enabling Async Javascript has 'broken' the javascript delivery. Should this happen to you, I highly recommend installing the Autoptimize plugin which will combine your javascript, further enhancing pagespeed and eliminating this issue.
/>

Async Javascript Method

Please select the method (async or defer) that you wish to enable:
Method /> Async /> Defer

Script Exclusion


Please list any scripts which you would like excluded from being Async/Defered during page load. (comma seperated list eg: jquery.js,jquery-ui.js)
Exclusions

Async Javascript For Plugins


Note: This will attempt to add the 'async' or 'defer' attribute to scripts loaded via a plugin (ie, not via 'wp_enqueue_script'). If you have a plugin that you would like added to this list please email support@cloughit.com.au

Autoptimize -

/>
' tasks called via wp_enqueue_script using the 'clean_url' filter * * @param string $url url being processed * @return string $url modified url string */ add_filter('clean_url','async_js',11); function async_js($url) { $aj_enabled = (get_option('aj_enabled') == 1) ? true : false; $aj_method = (get_option('aj_method') != 'async') ? 'defer' : 'async'; $aj_exclusions = get_option('aj_exclusions'); $array_exclusions = explode(',',$aj_exclusions); if (false !== $aj_enabled && false === is_admin()) { if (false === strpos($url,'.js')) { return $url; } foreach ($array_exclusions as $exclusion) { if (false !== strpos(strtolower($url),strtolower($exclusion))) { return $url; } } return $url . "' " . $aj_method . "='" . $aj_method; } return $url; } // end async_js() /** * my_autoptimize_defer() * * Adds support for Autoptimize plugin. Adds 'async' attribute to '