Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Optimising delivery with dynamic deferred scripts and localStorage caching Reply To: Optimising delivery with dynamic deferred scripts and localStorage caching

#237013
Shikkediel
Participant

This is coming along nicely. :-)

I’m doing a last modified and size check on the scripts so that the visitor always gets the latest version. Something regular cache can’t do.

B-)

Because of loading async, I’m no longer using what has always been ultimately handy :

$(document).ready(function() {});

That’ll actually get ignored now but I’ve noticed it gets triggered quite a bit later than self-invoking functions which I’m now using instead. Those will get executed as early as possible with the defer attribute in place.

Looks like when deferred dynamic links are created, using a doc ready wrapper might fire after window onload. So that event won’t be “heard” before the script is executed and any references inside it won’t trigger.

In case the progress of parsing is needed after all, there’s always document.readyState although interactive seems buggy on several platforms.

Apparently localStorage can only be accessed synchronously (still reading up on the whole main thread thing) so only a single small file is pulled out at first to see if any files were stored already. Other retrieval of data, updating and saving to it is postponed as much as possible to not interfere with document parsing.

Just posting at the lack of blog, I guess. :-D