Defer parsing of JavaScript - possible ?
Google page Speed tells, that on my vanilla home page about 120kB of JavaScript code should be deferred (I.e. /js/library/jquery.js, js/global.js etc.)
Is it posiible, and if so, how can in make it ?
Best Answers
-
422 MVP
Try this.
http://www.webpagetest.org/forums/showthread.php?tid=7897&pid=13818#pid13818
Using defer only applies to ie
There was an error rendering this rich post.
0 -
S ✭✭
Plugin <Page Speed> can do this. But it cannot handle with dependent inline scripts (*), they will be broken.
* dependent inline scripts, I meant such as jQuery().ready(){...};
0 -
Todd Vanilla Staff
I recently added support for
<script defer="defer" ... >
. This is supposed to do the same thing, but it doesn't work in as many browsers. It worked just fine in Firefox and chrome for me. IE supposedly invented the attribute so I'll assume it works there too.Which scripts can be deferred is is another question. I don't think jQuery is one of them since pretty much every other script makes use of
jQuery.ready(...)
.0
Answers
@Todd
Vanilla Forums COO [GitHub, Twitter, About.me]
Try this.
http://www.webpagetest.org/forums/showthread.php?tid=7897&pid=13818#pid13818
Using defer only applies to ie
There was an error rendering this rich post.
The seemingly adopted and preferred method is using async.
There was an error rendering this rich post.
Plugin <Page Speed> can do this. But it cannot handle with dependent inline scripts (*), they will be broken.
* dependent inline scripts, I meant such as jQuery().ready(){...};
I recently added support for
<script defer="defer" ... >
. This is supposed to do the same thing, but it doesn't work in as many browsers. It worked just fine in Firefox and chrome for me. IE supposedly invented the attribute so I'll assume it works there too.Which scripts can be deferred is is another question. I don't think jQuery is one of them since pretty much every other script makes use of
jQuery.ready(...)
.