How to Add the Async Flag to the Script Produced by Autoptimize

WpFASTER Code Leave a Comment

To add the async attribute to the script produced by Autoptimize, copy and paste this code snippet — in plain text — to your functions.php file, or, add it with a plugin like Code Snippets.

add_filter('autoptimize_filter_js_defer','my_ao_override_defer',10,1);
function my_ao_override_defer($defer) {
 return $defer."async ";
}

Leave a Reply

Your email address will not be published. Required fields are marked *