Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

integrity

Subresource Integrity: give a script or stylesheet the hash of the exact file you expect, and the browser refuses to use anything else.

Overview

The integrity attribute carries a cryptographic hash of the file you expect. The browser hashes what it downloads, and if the two do not match it refuses to run the script or apply the stylesheet, and fires an error event. This is Subresource Integrity (SRI). It protects you when a CDN or other third-party host is compromised or changes a file under a URL you already use.

SRI fails closed. A wrong hash blocks the file. So does a cross-origin file loaded without crossorigin: the browser cannot check a no-cors response, so it refuses it rather than running it unchecked.

Applies to: <script src> (classic and module) and <link> with rel="stylesheet", rel="preload" or rel="modulepreload". Import maps also have an integrity section for modules (see below).

Both tags load the same file. The first has its current hash and runs. The second has the hash of an earlier version, so the browser blocks it and logs an integrity error.

Values

One or more space-separated hashes, each written algorithm-base64digest. An empty value means no check. A value with no valid hash in it also means no check, so a typo in the prefix silently turns SRI off.

PrefixDigest length (base64)Notes
sha256-44 charactersMinimum allowed.
sha384-64 charactersThe usual choice.
sha512-88 charactersStrongest.

Several hashes: the browser keeps only the hashes that use the strongest algorithm present, then accepts the file if any of those match. Mixing sha256 and sha384 adds no strength (the sha256 one is ignored). Several hashes of the same algorithm are useful when a URL may legitimately serve one of a few known files, for example during a rollout.

Examples

Generating a hash

Hash the exact bytes that will be served, from a copy you trust:

Loading Vanilla Breeze from a CDN with SRI

The Quick Start uses a URL with no version (unpkg.com/vanilla-breeze/…), which the CDN redirects to the newest release. That is convenient, but it cannot be combined with SRI: the next release changes the bytes and the hash stops matching. Pin an exact version and add the hashes. These are the real hashes of the 0.5.0 entry files:

Module scripts are always fetched with CORS, so crossorigin is technically optional on the script tag; keep it for clarity. Recompute the hashes whenever you change the version.

Preloads and modulepreload

A preload must carry the same integrity (and crossorigin) as the tag that uses the file, or the preloaded response cannot be reused.

Import map integrity

The integrity attribute covers one file. Modules that file imports, statically or with import(), are separate requests with no hash. An import map's integrity section maps module URLs to hashes, and the browser checks them whenever those URLs load as modules.

In Vanilla Breeze

SRI on the VB entry tags covers those two files only. The full bundle loads more on demand, and none of it is covered:

  • Packs (dist/cdn/packs/<name>.full.js and .full.css), loaded with import() and a created <link> when a pack is activated (activateBundle() in src/lib/bundle-registry.js).
  • Themes that are not built in, added as <link> elements by src/lib/theme-loader.js.
  • The autoload build (vanilla-breeze-autoload.js), which fetches each component's chunk listed in components/manifest.json.
  • Third-party modules: <diagram-wc> imports Mermaid from cdn.jsdelivr.net at a pinned version (override with window.VB_MERMAID_URL).
  • Fonts and other url() requests made by the stylesheet.

For full coverage, either self-host dist/cdn/ (then you control every byte and the question goes away), or add import map integrity entries for the module chunks you use. Import maps do not cover stylesheets added with <link>.

Security

  • SRI protects third-party hosting. For files on your own origin it only guards against tampering in caches or on the CDN in front of you.
  • Generate hashes yourself from a reviewed copy, not from the host you are trying to protect against.
  • Pair it with a CSP. SRI checks the files you list; a Content Security Policy (nonce) stops injected tags from loading anything else.

Browser support

integrity on <script> and <link>: all browsers (Chrome 45, Firefox 43, Safari 11.1). Import map integrity: Chrome 127, Firefox 138, Safari 18 (MDN browser-compat-data, November 2026).

Gotchas

  • Forgetting crossorigin on a cross-origin classic script or stylesheet blocks it, even with the right hash. The server must also send Access-Control-Allow-Origin.
  • Floating versions (@latest, @0.6) break as soon as the file changes.
  • Byte-exact. A CDN that re-minifies or re-compresses content differently changes the hash. (Transfer encoding such as gzip does not; the hash is of the decoded body.)
  • Hash tools: openssl ... | openssl base64 -A prints one line. Wrapped output or a hex digest is not valid in the attribute.
  • Bundlers do not add SRI by default; Vite, webpack and others need a plugin.

Related

Which to choose

  • A pinned file from a public CDN — integrity plus crossorigin="anonymous".
  • A module graph from a CDN — integrity on the entry plus import map integrity for the rest, or self-host.
  • Your own files — self-host with a CSP; SRI is optional.
↑