vfunc.js

Deployment and cache

Files

FileUse
vfunc.js / vfunc.min.js<script> development / production (global vf)
vfunc.esm.js / vfunc.esm.min.jsES module development / production
vfunc.legacy.min.jsIE11 / Edge IE mode
plugins/update.min.js, plugins/update.esm.jsthe update plugin
css/vfunc.tokens.cssoptional tokens

Every file has a source map. Files are minified, never obfuscated.

CDN: exact version + SRI

<!-- Production: exact version + SRI -->
<script src="https://cdn.jsdelivr.net/npm/vfunc@1.2.0/dist/vfunc.min.js"
        integrity="sha384-yTR0o8US3nk+D1XIBAsv1O/lMFA5tV3V021xPo8yxyqnBNSxi1rqINVvBOykAEkK"
        crossorigin="anonymous"></script>

<!-- IE11 / Edge IE mode -->
<script nomodule src="https://cdn.jsdelivr.net/npm/vfunc@1.2.0/dist/vfunc.legacy.min.js"
        integrity="sha384-C9OzCaS/HB5/07dcKyjjbr4IKr2mYTp7X2yaKG5cc9GL3H+fbU7BI6Kdu9Q/U90O"
        crossorigin="anonymous"></script>
npm i vfunc@1.2.0

import vf from 'vfunc';

integrity values differ per version and file; the ones above belong to the version this site was built from. Never load polyfills from a third-party CDN.

Making every release arrive

Without a build there are no hashed file names, and app.js?v=2 does not reach the modules it imports. Use four layers together:

  1. Cache headers: index.html and version.json with Cache-Control: no-cache.
  2. Version folders: copy each release into /1.0.3/… and point index.html at it. Every sub-module becomes the new version at once. The starter's node tools/release.mjs 1.0.3 does it by copying only.
  3. The update plugin: open pages switch to the new version on the next screen change.
  4. Pinned versions: exact versions + SRI for every file from another domain.
PathCache-Control
/index.html, /version.jsonno-cache
/<version>/…public, max-age=31536000, immutable

Settings for Apache, Nginx, IIS, Tomcat, Netlify and GitHub Pages are in the starter's deploy/ folder.

Service Workers

The most common cause of "the update never arrives". Add one only if you need offline use: keep HTML network-first and prepare a way to unregister it.

Security checklist