Skip to content

XON 2.1.1

Choose a tag to compare

@oncebuilder oncebuilder released this 01 Dec 09:08
· 1 commit to main since this release

Changed - speed

  • A row's plain words with blanks (data-class-selected="{id} == app.selected", data-attr-*, data-text,
    data-if in a data-each row) are compiled once per list, with each blank a parameter (the row's value, never parsed
    into the condition), and need no effect per row: one effect per word and list. When the condition compares the list's
    key with one value, a change of that value updates the two rows it concerns. Rows stay in the fast cloned form
    (before: each row was rendered as markup and each condition parsed and tracked on its own - 4-10x slower).
  • The wiring of the page runs at background priority (scheduler.postTask, else a long enough
    requestIdleCallback moment, else a timer) and no longer queries 30+ attribute selectors over the whole page: the
    plain words are found in the same pass as data-attr-* / data-class-*. A first click no longer waits for it
    (Firefox, 10,000 elements: click to painted 18 ms -> 0.4 ms).
  • Boot build: without requestIdleCallback (Safari) the engine loads after the first frame is drawn (a frame, then
    a task), not before the first paint (WebKit, 10,000 elements: ready to painted 265 ms -> 41 ms).
  • Boot build, first click as the engine arrives: the veil that hides data-if / row markup until the engine runs
    is now switched off with a class of <html> (the sheet stays), not by taking the style sheet away - that restyled
    and repainted the whole page in the frame of the first click; a page with nothing to hide drops it once parsed.
    Without idle scheduling (Safari) the engine's search of the whole page runs in ~1 ms slices. Boot build, first click
    on the last of 10,000 elements, click to painted (total time, median of 7): WebKit 28.4 ms before this fix -> 11.2 ms
    (other libraries 7.5-10.5 ms); Firefox 47.9 ms in 2.1.0 -> 0.26 ms.
  • Core size: tabs are the new part tabs (loaded by data-tabs or the first $xon.ui.tab), the word data-load is
    bound by the part request (which every request needs anyway), and the in-place patch of a changed markup-form
    row is in the part morph (loaded with such a list; without it the row is replaced).

Fixed

  • An explicit render (xon.render(), the dashboard build at start) no longer binds the row markup of a data-each that
    the list already took out of the page (it reported XON129 for every {blank} in a plain word).

Added - AI-ready

  • AGENTS.md: how to write XON 2.1 correctly, for AI coding assistants and people - the rules, a cheat sheet of the
    symbols and every plain word, the settings and the API, the security essentials, common mistakes with their fixes,
    and copy-ready patterns (counter, form, list with a key, fetch into a target, navigation, component, boot build).
    Every pattern is a test: it passes tools/lint.js and runs in Chrome on every build (tests/browser/docs.test.js).
  • llms.txt (the llmstxt.org index of the docs) and llms-full.txt (AGENTS.md, README and
    every page of docs/ in one file).
  • tools/llms-build.js writes llms.txt, llms-full.txt and the tables of AGENTS.md from docs/ and the vocabulary;
    ./build.sh --check fails when one of them is stale.
  • tools/lint.js --json: a list of { file, line, col, code, severity, message, fix: { description, replacement? }, rule };
    --stdin (with --name), exit codes 0 (no errors) / 1 (errors) / 2 (the command was wrong). See docs/debugging.md.
  • dist/xon.schema.json: a JSON Schema (draft 2020-12) of every attribute, symbol, setting and API name, written
    from the vocabulary by tools/schema-build.js (checked by ./build.sh --check). #/$defs/attributes checks the
    XON attributes of one element, #/$defs/config the settings. See docs/index.md, "Machine-readable files".
  • The vocabulary lists the settings of xon.config() / window.xonConfig (config, in docs/vocabulary/core.json).

Security

  • The Trusted Types policy xon is narrow (all builds). createHTML and createScript accept only the string
    XON's own sink is handing over at that moment (its callers in the core parse only into inert containers: the
    sanitizer's <template>, a DOMParser document, a <textarea>; script text only for the inline scripts of content
    your script trusts with its scripts); any other string is refused with XON255. createScriptURL accepts only
    http(s) addresses of this page's site or of the site of the XON script - the rule of the part loader - and refuses
    anything else with XON256. Before, the policy passed every string through, and xon._.scriptURL() (reachable
    by any page script) turned any address into a trusted script address; it is gone - the part "offline" uses
    xon._.policy. The boot build's policy follows the same
    rules (the engine gives it the markup rule when it takes over; until then it refuses markup).
  • Under Trusted Types a <script src> of another site inside trusted content is left out and reported (XON256)
    instead of being loaded.

Changed

  • xon._.policy: the policy itself, for the parts and for tests (it refuses what it was not handed).
  • Core 30,720 bytes gzip (limit 30,720, unchanged): the new policy rules were paid for by sharing one address check
    (ours) between the policy, the part loader and xon.config({ parts }), and by moving the worker address helper
    out of the core.

Benchmarks (script time, total time with paint in Chrome/Firefox/WebKit, and a local js-framework-benchmark run): bench/RESULTS.md