Defer Parsing Of Javascript

Hi there,

Though this issue has similar thread on the forum, I wasn't able to figure out a solution for the defer parsing issue for javascript. I ran my website for a gtmetrix score and it showed a score of 0 along with a grade of F for the same. I am running cs-cart mv 4.1.3 and the following description came along with the defer parsing error

“[color=#436688][font=Arial, Tahoma, Verdana, sans-serif][size=3]586.5KiB of JavaScript is parsed during initial page load. Defer parsing JavaScript to reduce blocking of page rendering.[/size][/font][/color]”



As per my knowledge, js can be deferred asynchronously using “[color=#282828][font=arial, verdana, tahoma, sans-serif] defer async[/font][/color]” in the script tag.

But as the issue is there in the combined js i.e.

[color=#ff0000]http://www.mysite.co…66.js?ver=4.1.3[/color]

[color=#000000]How can I fix it?[/color]

[color=#000000]I'm also attaching the screenshot for the same.[/color]



Thanks in advance

[color=#000000]Regards[/color]

[color=#000000]NaMo[/color]

error.PNG

[quote name='NaMo' timestamp='1397986118' post='181971']

Hi there,

Though this issue has similar thread on the forum, I wasn't able to figure out a solution for the defer parsing issue for javascript. I ran my website for a gtmetrix score and it showed a score of 0 along with a grade of F for the same. I am running cs-cart mv 4.1.3 and the following description came along with the defer parsing error

“[color=#436688][font=Arial, Tahoma, Verdana, sans-serif][size=3]586.5KiB of JavaScript is parsed during initial page load. Defer parsing JavaScript to reduce blocking of page rendering.[/size][/font][/color]”



As per my knowledge, js can be deferred asynchronously using “[color=#282828][font=arial, verdana, tahoma, sans-serif] defer async[/font][/color]” in the script tag.

But as the issue is there in the combined js i.e.

[color=#ff0000]http://www.mysite.co…66.js?ver=4.1.3[/color]

[color=#000000]How can I fix it?[/color]

[color=#000000]I'm also attaching the screenshot for the same.[/color]



Thanks in advance

[color=#000000]Regards[/color]

[color=#000000]NaMo[/color]

[/quote]



Hi,



I did not read the previous topic, but there is the “dev_js” tweak in the config.local.php file which allows to disable js files compilation. Please check

How would having to download 20 individual JS files and parse them individually be any better than a single file (I.e. one transaction)? How would this address the OP's issue?

Then what should be the correct way @tbirnseth?

[quote name='tbirnseth' timestamp='1398127609' post='182032']

How would having to download 20 individual JS files and parse them individually be any better than a single file (I.e. one transaction)? How would this address the OP's issue?

[/quote]



I am not sure how the gtmetrix works. But first I would try to use the mentioned tweek and check the response. Hope it is clear.

Hi eCom,

Already the 'dev_js' is set to false in our config.local.php.

But still defer parsing error is occuring.

The “defer async” should do the trick. My point was that breaking a single file into its individual components won't address the issue you are trying to solve.

So does that mean, inserting “defer async” to all the js references present in the website?

Isn't there an addon for it?

Also how does cloudflare do it then? They have a simple option from the dashboard to minify css and defer async js and many things like that.

Suggest you submit it as a bug in bugtracker and see what response you get from the developers (or helpdesk).

This really only applies to JS files, not all script entries. I.e. the inline stuff should not be affected since it's part of the page rather than a reference to it.



I'm not sure where to recommend for you to change the default attributes that are generated from the smarty {script } special plugin.

I.e. to change the generation of:

```php


```

to

```php


```

I looked around the plugin code a bit but didn't see anything obvious. It might be as simple as adding an argument to the script smarty tag, but I'm not sure.



You really only want to do this for the one combined JS file.