Defer parsing of javascript

Hearing a lot about deferring parsing of javascript to improve load times. Is this something I want to do in Rapidweaver? Use mostly Foundation. And HOW?
thanks,
Tim

If you use Foundation then you can add a Page Speed child to the SEO helper stack and this will move all JS calls to the bottom of the body.

Do you always want to do this or go further and defer load JS scripts?

Probably not if you are using RW.

On several occasions, using page speed will break stacks that rely on working before the page has fully rendered - think tabs / sliders etc that need to size themselves dependent on their container. Delaying the load of their JS arbitrarily may have the same effect as if they were in a hidden area and screw up the calcs.

Deferred loading would mean that you have to physically edit the syntax of all your JS links after the page has been published - and of course do it again and again each time you republish.

Remember, above all, that RapidWeaver and Stacks is a complex modular system with components that have no knowledge of each other, all on your page. If you were writing it by hand instead of using a drag and drop lego system then yes, you would optimise the way things load but, in general, Stacks has to take the pragmatic and safety first approach to make sure that everything works together. Themes of course do have more control over these things and some themes have been optimised for Google Page Speed.

Also remember that deferring will not reduce load speed, it will only reduce time to render - it will still take the same amount of time to load the scripts over all and you need to be 100% sure that anything deferred is not going to cause a flash of unstyled content or otherwise break things.

5 Likes

Thanks, Tav, for an excellent explanation.

Thank you so much for explaining how this works. A huge help. I’ve seen it discussed all over the internet but you put it more clearly than anyone else. Thanks Tav!

1 Like