What Is The Fastest Way To Load JavaScript

JavaScript

There are a few things you can do:

  1. Load the HTML and CSS before the javascript. This gives the browser everything it needs to layout the page and renders it. This gives the user the impression that the page is snappy. Place script tags or blocks as close to the closing body tag as possible.
  2. Consider using a CDN. If you are using any of the popular libraries like JQuery many companies (e.g. google, yahoo) operate free CDNs that you can use to load the libraries.
  3. Load code from an external file instead of an embedded script. This gives the browser the opportunity to cache the JS content and not have to load it at all. Successive page loads will be faster.
  4. Turn on zip compression on the webserver.

Leave a Reply

Your email address will not be published. Required fields are marked *