Eliminate render blocking javascript

After running my WordPress site through Page Speed Insights I’m told that I need to eliminate render blocking javascript.
So I have moved the vast majority of javascript to just before the closing body tag but the warning still appears in Page Speed Insights.

Can anyone suggest what I can do to resolve this issue please?

The site is http://www.stewartandsonsroofingliverpool.co.uk/

Thanks in advance

3 Answers
3

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