Magento – Defer Parsing of JavaScript

ce-1.8.1.0csshtmljavascriptPHP

i analyzed my website on Gmetrix.com for for optimization and the result was this:

361.0KiB of JavaScript is parsed during initial page load. Defer parsing JavaScript to reduce blocking of page rendering.

http://mysite.com/media/js/b5de567c1b6b9d971394b4d4887370a1.js (351.7KiB)
http://mysite.com/ (9.3KiB of inline JavaScript)

Defer parsing of JavaScript

In order to load a page, the browser must parse the contents of all
tags, which adds additional time to the page load. By
minimizing the amount of JavaScript needed to render the page, and
deferring parsing of unneeded JavaScript until it needs to be
executed, you can reduce the initial load time of your page.

how to solve it?

Best Answer

Solution 1. Best solution: Less Javascript

or find out which JS loads the part 'above the fold' and

Solution 2. load that in header + de rest of the JS in footer

Solution 3. or use the attribute for the JS below the fold, which prevents parsing from blocking the initial page load by deferring it until the browser's UI thread is not busy doing something else.