Defer loading of javascript

Discussions about the Enuuk Platform in general - both the GPL and Commercial versions
Post Reply
bamse
Posts: 220
Joined: Mon Feb 06, 2012 12:05 pm
Contact:

Defer loading of javascript

Post by bamse » Sun Sep 08, 2013 6:45 am

I am trying to defer the loading of javascript using the method outlined in https://developers.google.com/speed/doc ... rLoadingJS

Tried this with the fancybox js file and from the timeline in developer tools it seems that the file is loaded later (after the red line). However for some reason fancybox does not work. Any ideas on what could be the problem.

bamse
Posts: 220
Joined: Mon Feb 06, 2012 12:05 pm
Contact:

Re: Defer loading of javascript

Post by bamse » Sun Sep 08, 2013 11:47 am

I think the problem is that global.js needs to be loaded after fancybox. Defering global.js as well and after fancybox, seems to solve this problem.

Now I only need to figure out whether there is any code in global.js which should not be defered (because it is needed for rendering)...

RWAP
Site Admin
Posts: 748
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Re: Defer loading of javascript

Post by RWAP » Sun Sep 08, 2013 1:27 pm

Hmm - what I did was to defer fancybox and move the code which initiates fancybox out of global.js and into the offerdetailsHeader.php

I also defer the non-english plugins for jquery Countdown and the datepicker

bamse
Posts: 220
Joined: Mon Feb 06, 2012 12:05 pm
Contact:

Re: Defer loading of javascript

Post by bamse » Sun Sep 08, 2013 8:25 pm

Why didn't you defer more?

Using pagespeed to "profile deferrable javascript", I get the message:
100% of the JavaScript loaded by this page had not been invoked by the time the onload handler completed.
which seems to suggest that all javascript could be deferred.

Also looking at the actual code, as far as I can see it seems to be mostly user-activated stuff. The only thing which I am not sure is:

1) IE hacks
2) code for countdown

or am I missing something?

RWAP
Site Admin
Posts: 748
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Re: Defer loading of javascript

Post by RWAP » Mon Sep 09, 2013 6:46 pm

Some of it depends on changes I have made to a few sites and the need for some of the code (especially jQuery) to be loaded so it can start rendering aspects (as I use jquery plugins for ensuring rounded buttons for example).

That said, I have Mod_Pagespeed enabled on my sites to speed things up, and this automatically defers javascript - my own site (sellmyretro.com) then works fine with all javascript being deferred.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest