6

I was testing the web page loading with Google PageSpeed tool. The result says "Eliminate render-blocking JavaScript and CSS in above-the-fold content" for

<script type='text/javascript' src='http://example.com/wp-includes/js/jquery/jquery.js?ver=1.11.2'></script>
<script type='text/javascript' src='http://example.com/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.2.1'></script>

The source code is:

<head>
...
...

<script>(function(){document.documentElement.className='js'})();</script>
...
...
</head>

I'm keen to add a async or defer tag. How can I achieve this?

4
  • Does that simple script affect the page speed that much? Commented Jul 24, 2015 at 16:59
  • This is what the analysis result says: Consider Fixing: Eliminate render-blocking JavaScript and CSS in above-the-fold content Your page has 2 blocking script resources and 4 blocking CSS resources. This causes a delay in rendering your page. None of the above-the-fold content on your page could be rendered without waiting for the following resources to load. Try to defer or asynchronously load blocking resources, or inline the critical portions of those resources directly in the HTML. Remove render-blocking JavaScript: Commented Jul 24, 2015 at 17:03
  • Erm. Google PageSpeed checks for existence of such scripts, but it doesn't evaluate their speed or something. You can move that script to the end of <body> and check again; I don't think the difference will be of any meaning. Commented Jul 24, 2015 at 17:05
  • Did you find a solution ? Commented Jul 8, 2017 at 16:02

1 Answer 1

1

From MDN about the async attribute:

It has no effect on inline scripts (i.e., scripts that don't have the src attribute).

The same is true about the defer attribute.

Basically, if you really want to get rid of the error, just move that to just before the </body> tag.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.