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

script

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 type attribute 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>.

From the CDN, use the bundled entry instead. See Quick start.

Execution Order

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.

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.

Structured Data

A type="application/ld+json" block carries schema.org metadata for search engines. It is inert: the browser does not run it.

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.

Attributes

Attribute Description
src URL of an external script. Without it, the element's text is the script.
type Omit for classic; module, importmap, speculationrules, or a data MIME type such as application/ld+json.
async / defer Download without blocking the parser. defer only applies to classic scripts with src; async works on modules too.
blocking="render" Hold the first render until this script has run. Use it sparingly, for scripts that must run before paint.
nonce One-time token matching the CSP script-src directive.
integrity Subresource Integrity hash; the script is refused if the file does not match.
crossorigin CORS mode for the request. Needed for integrity checks and full error details on cross-origin scripts.
nomodule Skip this classic script in browsers that support modules. Every browser VB supports runs modules, so VB pages do not need it.
referrerpolicy, fetchpriority Referrer sent with the request, and a download-priority hint (high, low, auto).

The element also accepts the global attributes.

Accessibility

  • 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.

Related

  • async / defer - Non-blocking script loading
  • blocking - Render-blocking scripts and styles
  • nonce - CSP nonces for inline and external scripts
  • <noscript> - Fallback content when scripts are disabled
  • <template> - Inert HTML for scripts to clone
  • <link> - rel="modulepreload" for module dependencies
  • Quick start - Adding VB's CSS and JS to a page
↑