Browser Helpers
Utility functions for working with browser operations.
Functions
Section titled “Functions”| Function | Description |
|---|---|
createFileStore | Creates a file store on a named Cache API cache: keep a computed set of files (a bake, a download, extracted layers) un… |
decodeImage | Loads an image and waits until it is decoded, so it can be painted without a flash or a decoding pause (e.g. |
loadFont | Loads a font and registers it in `document.fonts`, so CSS and canvas can use `family` right away. |
matchesMedia | Whether the document currently matches a CSS media query. |
observeIntersection | Calls `callback` each time `element` enters or leaves the viewport (or `options.root`), with an `IntersectionObserver`… |
observeResize | Calls `callback` each time the size of `element` changes, with a `ResizeObserver` dedicated to it. |
onPointerIntent | Tells a tap from a drag, and hover from touch, on one element: the pointer-event logic every draggable or clickable wid… |
prefersReducedMotion | Whether the user asked the system to reduce motion (`prefers-reduced-motion: reduce`). |
preloadImages | Loads and decodes several images with decodeImage, a few at a time, with `mapSettled` from `helpers4/array`. |
reflectAttribute | Defines a property on `element` that is backed by an HTML attribute — what a custom element needs for `<my-card heading… |
requestWorker | Runs one job in a module worker: starts it, posts the request, relays its progress, resolves with its result and ends i… |
sha256Hex | The SHA-256 digest of some data as a hexadecimal string, optionally cut short: a compact content key, not a security ch… |
watchMedia | Calls `listener` each time a CSS media query starts or stops matching. |
whenIdle | Runs `callback` when the browser is idle, with `requestIdleCallback`, for work that can wait (prefetching, analytics, w… |
