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…
Loads or embeds JavaScript, or carries a data block such as JSON-LD or an import map. Covers classic vs module scripts, async/defer, render blocking, CSP nonces and integrity.
Description
The <script> element either runs JavaScript or holds a data block. The typeattribute decides which:
No type (or a JavaScript MIME type): a classic script.
type="module": an ES module. Modules are deferred by default, run in strict mode, have their own scope and can use import.
type="importmap": an import map that tells the browser how to resolve bare specifiers such as import 'vanilla-breeze'.
Any other type, such as application/ld+json: a data block. The browser never executes it.
Vanilla Breeze is HTML-first: pages render and work without JavaScript, and scripts enhance them. The framework itself ships as one ES module.
Loading Vanilla Breeze
Load the framework as a module. A module never blocks HTML parsing, so it can go in the <head> or at the end of <body>.
Classic scripts without async or defer block the parser and run immediately. Modules and defer scripts wait until the document is parsed, then run in document order before DOMContentLoaded. async scripts run as soon as they arrive, in no fixed order.
Execution order
<head><script>/* 1. classic: runs now, body not parsed */</script><scripttype="module">/* 3. module: deferred until parsing ends */</script><scripttype="application/ld+json">{ "@type": "WebPage" }</script></head><body> …<script>/* 2. classic at end of body: runs during parsing */</script></body>
Form
Blocks parsing
Runs
<script src>
Yes, while it downloads and runs
Immediately, in order
<script defer src>
No
After parsing, in document order
<script async src>
No (runs when ready, pausing the parser briefly)
As soon as downloaded, any order
<script type="module">
No
After parsing, in document order (like defer)
<script type="module" async>
No
As soon as it and its imports are ready
Import Maps
An import map must come before any module that uses the mapped names. It lets hand-written modules import VB by name without a bundler.
A type="application/ld+json" block carries schema.org metadata for search engines. It is inert: the browser does not run it.
JSON-LD
<scripttype="application/ld+json">{"@context": "https://schema.org","@type": "Article","headline": "Getting started with Vanilla Breeze"}</script>
Security: CSP, Integrity and CORS
With a strict Content Security Policy, give every script the per-response nonce named in the policy's script-src. For scripts from a CDN, add integrity so the browser refuses a file whose hash has changed, and crossorigin so the integrity check can run on a cross-origin response.
Script content is never rendered or announced. What matters is the result: content a script adds or changes must stay keyboard-operable and announced (use native controls, and live regions for status changes).
Do not make core content depend on a script. If it is missing or fails, the page should still read and work; provide a <noscript> message only where an enhancement really has no HTML fallback.
Avoid blocking="render" on slow scripts: a blank screen is a barrier for everyone, not only for assistive technology users.