You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b011705
Browse filesBrowse the repository at this point in the historyBrowse files
feat(html): minify the script an event handler attribute holds
Every event handler content attribute — `onclick` and its 93 siblings —
is offered to `renderEmbeddedSource` as JavaScript, with `as:
"event-handler"` saying it is a function body rather than a script, the
way a `style=""` is offered as a block's contents rather than a whole
sheet. The answer is written back escaped for the delimiter it lands in,
and only where it spells shorter than the source does.
`htmlMinify` spends that production, since a JavaScript minifier takes
whole scripts and no `as`: the function the body belongs to goes out and
the body of the one answered comes back. So a `return` — what an author
writes to cancel an event — is minified in the production it is in,
rather than skipped for failing to parse as a script.
The handler table is derived from webref's HTML IDL alongside the other
reflected-attribute tables, so which names are handlers on which
elements is generated rather than listed.
* @property {(boolean | "smart" | "all")=} removeImpliedTags how much of the `<html>` / `<head>` / `<body>` shell §13.1.2.4 lets the parser imply may be left out: `"smart"` leaves out only the `<html>` start tag, `true` (or `"all"`) all six, `false` none (default `"smart"`)
8947
8953
* @property {boolean=} deferSrcdoc whether an `<iframe srcdoc>` is among what `deferEmbeddedSource` collects (default true); false for a caller that minifies them itself, which keeps the attribute on the normal path and its shorter delimiter
8948
8954
* @property {DeferredEmbeddedSource[]=} deferEmbeddedSource collects what `renderEmbeddedSource` would be offered instead of offering it, for a caller whose renderer is asynchronous: the print leaves a marker for each and `finish` puts the answers in their place, so one parse serves both. A `style=""` stays with the built-in CSS minifier, whose text this print reads back to decide how the attribute is written. Takes precedence over `renderEmbeddedSource`
8949
-
* @property {EmbeddedSourceRenderer=} renderEmbeddedSource renders each nested body this document embeds — an inline `<style>`, every `style=""` (handed over as a whole stylesheet, SVG's and MathML's included), a `<script>` holding JSON or JavaScript, an `<svg>` subtree, and the document an `<iframe srcdoc>` holds (decoded, and written back escaped). Replaces the built-in CSS and JSON minifiers wherever it answers, and returning anything but text falls back to them; it is the only way inline JavaScript, SVG and a nested document are reached at all
8955
+
* @property {EmbeddedSourceRenderer=} renderEmbeddedSource renders each nested body this document embeds — an inline `<style>`, every `style=""` (handed over as a whole stylesheet, SVG's and MathML's included), a `<script>` holding JSON or JavaScript, every event handler attribute, with `as: "event-handler"` saying it is a function body rather than a script — the production a `return` at its top level is in, which a renderer taking whole scripts has to wrap before it can read (webpack's own `htmlMinify` does) — an `<svg>` subtree, and the document an `<iframe srcdoc>` holds (decoded, and written back escaped). Replaces the built-in CSS and JSON minifiers wherever it answers, and returning anything but text falls back to them; it is the only way inline JavaScript, SVG and a nested document are reached at all
0 commit comments