JavaScript resources are parser-blocking so consider doing this to speed-up your JavaScript on your website:
- If the script does not affect the DOM tree (does not add or modifies HTML) and is not affecting stylesheets then you can put it inside external file, call it inside <head> element and add an “async” attribute
<head> ... <script src="analytics.js" async></script> ... </head>
- defer Javascript execution (The script tag can also take a
deferattribute, in the same way that it can take anasyncattribute. The difference is that withdefer, the script waits to execute until after the document has been parsed, whereasasynclets the script run in the background while the document is being parsed.) - Minify, compress and Cache JS.
Leave A Comment
You must be logged in to post a comment.