1

I have tried ALL THE TECHNIQUES here, and I still cannot figure out how in Magento 1.9 I can get the javascript to not load above the fold, or after the page has loaded.

My website is dev.shielo.com

this is the page speed error i am getting from google:

58 / 100Speed

Should Fix: Eliminate render-blocking JavaScript and CSS in above-the-fold content Your page has 1 blocking script resources and 3 blocking CSS resources. This causes a delay in rendering your page. None of the above-the-fold content on your page could be rendered without waiting for the following resources to load. Try to defer or asynchronously load blocking resources, or inline the critical portions of those resources directly in the HTML. Remove render-blocking JavaScript: http://www.dev.shielo.com/…a/js/1baca94bb0796b5af64534b31746847a.js

  • All the techniques where? – nachito May 21 '15 at 20:11
  • I have tried all the techniques on this forum - using defer and asyncronis. Most of the responses are not complete, so I am unsure how to implement it. – styzzz May 22 '15 at 20:51
1

forget about that, just enable FoomanSpeedster.
you have to look for "time to first byte" optimization, it has higher priority.

Reduce server response time - is your problem.
run https://github.com/AOEpeople/Aoe_Profiler to see if magento has some slow parts

i guess you need to configure php opcache and mysql optimization. also maybe magento cache is disabled.

then optimize images with
install these : gifsicle ImageMagick jpegtran pngcrush
https://github.com/mikebrittain/Wesley/blob/master/wesley.pl

  • I tried FOOMAN, but it DOES NOT help with deferring the javascript. My question specifically referred to Javascript delaying problem. – styzzz May 22 '15 at 19:58
  • you just dont understand whats going on. you will have to disassemble your javascripts and then it is possible to move some scripts to bottom, and some scripts closer to "body" tag, in fact yes, page will render much faster, BUT, this is absolutely pointless if your "time to first byte" is over 1 or 2 seconds. – user2857 May 23 '15 at 9:20
0

Google suggests you to put the initially needed CSS inline and load the rest of the CSS when the page load is ready. Same goes for the javascript. Include the "must have code" inline and load the "nice to have code" on page load as suggested here

Try adding the async attribute in script tag or defer attribute.

For example:

<script src="filename.js" async></script>
<script src="filename.js" async="async"></script>

or

<script src="filename.js" defer></script>
<script src="filename.js" async="async"></script>

I suggest you to use async, it loads the file only when needed. Defer attribute load the file at the end of the page, some time it will not perform its functionality required.

0

For other looking how to defer JS in Magento.

Magento 1.x uses a lot of inline scripts, which means it’s NOT possible to defer the loading of most of the default JS files included in a default Magento installation. If you defer the loading of those scripts you will receive tons of error because Magento will try to execute the inline scripts before the JS files have loaded.

0

The Mediarox Pagespeed extension allows to exclude inlined scripts by id and js files via reg expressions so it IS possible to defer your js. I am deferring all of my js except analytics (all of the default magento js files and inlined js aswell!) without any issues. However, this doesn't matter for Google Pagespeed results anymore, my results will be the same no matter if I defer my js or not.

By the way, the pagespeed extension works great with Fooman Speedster, there is no need to manually disassemble js files as it will merge the excluded scripts and load them after body start and merge the remaing scripts and load them before body end. But as I mentioned, your rating won't improve - it will most likely bring some kind of performance boost though.

For css the problem is somewhat different. Even if you include the critical css in your head and defer loading of your stylesheets via the Pagspeed extension, Google Pagespeed will still tell you that your css file is render blocking. Your ratings will go down even more if you server your css from a subdomain. I don't think this has anything to do with time to first byte and it seems the only way to fix this is to inject your css via js, I have tried using async and defer in my local.xml - this will change nothing I am afraid.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.