3

I am looking for a way to store almost all JS & CSS in localstorage. I know how to do it with CSS (seems to work without a hitch). However, if you try to store JS that has any HTML call like that will stop the saving to the local storage. Ideally I would just like to create a list of source files for the browser to download.

To give you an idea I am trying to store the Jquery UI js and Jquery in local storage. This way they only need be loaded once.

Doing this will drastically improve the speed of my application. I have already built in version control so that I can overwrite any old data.

one more thing....just to make it fun...I need a callback once everything has been downloaded so I can forward the user. (any ideas on how to do this?)

thanks all for any help!!!

m_gunns
  • 551
  • 1
  • 16
  • 29
  • possible duplicate of [Storing Objects in HTML5 localStorage](http://stackoverflow.com/questions/2010892/storing-objects-in-html5-localstorage) – Jason Jun 10 '11 at 00:12
  • 4
    This is pointless when you use correct caching – Petah Jun 10 '11 at 00:12
  • Please explain proper caching then. – m_gunns Jun 10 '11 at 00:18
  • Proper caching would be setting your Expires headers for your content. http://developer.yahoo.com/performance/rules.html#expires This is better because you are leveraging a proven methodology, works for all browsers and allows the content to be cached by intermediary servers. Also, 1MB of assets seems high. Compress and minify your assets if you aren't already. http://developer.yahoo.com/yslow/help/#guidelines – Ryan Doherty Jun 10 '11 at 01:52
  • This is an application. If you look at Jquery UI and Jquery lib. they are about .5mb if you make use of everything. All assets include quite a bit of things from config files, css, and js. The site has over a hundred pages. I am just trying to make use of localStorage. I really don't feel caching is the best way. I am trying to make use of newer methods...does everyone believe caching is the best method? – m_gunns Jun 10 '11 at 03:49
  • New version of GMail uses HTML5 based caching as far as I know: http://www.w3.org/TR/offline-webapps/#offline - and you can cache javascript files using this mechanism, too – Dan Esparza Jun 10 '11 at 22:53

1 Answers1

2

the browser should cache those resources, so storing them in localstorage isn't worth the headache.

hvgotcodes
  • 118,147
  • 33
  • 203
  • 236
  • well I am going to store almost all assets. If assets are up-to-date then they are only loaded 1 time. Since this is a web application the first time they come to the site everything is loaded which is about 1mb of assets. After that they are no longer needed and they pull from local storage and they aren't deleted when cache is. I happen to like this option but I am open to other suggestions. – m_gunns Jun 10 '11 at 00:23