📎 Webclip
Basket.js: A JavaScript Loader With LocalStorage-based Script Caching
Basket.js loads a small stub first, then checks whether other scripts are already cached in localStorage. If they are missing or expired, it fetches them with XHR and stores them for later loads.
Reading notes#
- Basket.js caches JavaScript files in localStorage instead of depending on the browser cache.
- The post says this approach is faster, citing tests from Google and Bing.
- It uses a Promise-based API built on RSVP.js to require scripts and inject them into the page.
- The author suggests trying a FileSystem API version to compare performance with localStorage.
- The post says IndexedDB was tried already and was slower than localStorage.
- It also suggests combining the idea with App Cache so an app can work offline with a small HTML stub that loads everything else from storage.
