Skip to content
Mikhail Davydov edited this page Oct 10, 2013 · 3 revisions
  • Flags: cache, cache_async, Property: version

You can store all your in-package modules and lmd itself in localStorage. (Disabled by default)

  1. Set config flag cache: true and add version: your_current_build_version property to your config file then build your LMD package - it will be created in cache mode. If no version - LMD package will run in default mode - without dumping modules
  2. Set config flag cache_async: true to cache require.async() requests in localStorage too
  3. Remove script tag <script src="out/index.production.lmd.js" id="source"></script> with LMD initializer:
<script id="lmd-initializer"
        src="../src/lmd_initializer.min.js"
        data-src="out/index.production.lmd.js"
        data-version="1.6.0"
        data-key="lmd"></script>
  • id - always lmd-initializer (do not change it)
  • src - path to lmd_initializer.js
  • data-key - localStorage key where all lmd code stored (do not change it)
  • data-version - content in localStorage must match this version
  • data-src - fallback if version do not match or no localStorage or error or no content

See Live example of LS cache

Note: version property from config and from data-version attribute must match to use code from localStorage! Yep! Each time you have to change config file and your html file!

Clone this wiki locally