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
  <script src="analytics.js" async></script>
  • defer Javascript execution (The script tag can also take a defer attribute, in the same way that it can take an async attribute. The difference is that with defer, the script waits to execute until after the document has been parsed, whereas async lets the script run in the background while the document is being parsed.)
  • Minify, compress and Cache JS.