News for hackers. Stuff that matters.

Idea: keep clientside js in localStorage

client side javascripters aim for minimal code, to optimise load times; but what if you didn't have to worry about that? My idea is to store slowly changing assets in localStorage and then just have a tiny js that loads them into the page.

has anyone attempted this before?

( 5 comments | on HN )
Re:Idea: keep clientside js in localStorage by willscott on Tuesday April 24, 2012 @12:37AM (#3882444)
Why would this be preferable to an application cache manifest?

http://www.html5rocks.com/en/tutorials/appcache/beginner/

Re:Idea: keep clientside js in localStorage by dominictarr on Tuesday April 24, 2012 @12:55AM (#3882493)
Ah, I didn't know about that. It might not be worthwhile since that already exists.

Except to give more precise, granular, control over updates. for example, (for example, with a merkle tree)

Re:Idea: keep clientside js in localStorage by daegloe on Tuesday April 24, 2012 @12:37AM (#3882441)
Is this really necessary when you already have browser caching? Which is fairly robust/mature across the market.
Re:Idea: keep clientside js in localStorage by dominictarr on Tuesday April 24, 2012 @12:56AM (#3882497)
the problem with browser caching is that you cannot control when you want it to update, except with a timeout.
Re:Idea: keep clientside js in localStorage by abend on Tuesday April 24, 2012 @01:09AM (#3882528)
Timeout isn't the only way. You could set a version variable on pageload, and have a conditional version check on init. If the versions match and localstorage exists, load from localstorage, if not, grab from the server and update.