Eliminate render blocking javascript

You can install a plugin to load your JavaScript asynchronously or try to do it manually adding code to your functions.php to load your scripts asynchronously.

This can get you started,

Warning

loading JavaScript asynchronously will cause several issues with dependencies:

/*function to add async to all scripts*/
function js_async_attr($tag){
  //Add async to all  scripts tags
  return str_replace( ' src', ' async="async" src', $tag );
}
add_filter( 'script_loader_tag', 'js_async_attr', 10 );

so you have to check your JS code and update it.

Leave a Comment