1
Fork 0

rustdoc: dedup search form HTML

This change constructs the search form HTML using JavaScript, instead of plain HTML. It uses a custom element because

- the [parser]'s insert algorithm runs the connected callback synchronously, so we won't get layout jank
- it requires very little HTML, so it's a real win in size

[parser]: https://html.spec.whatwg.org/multipage/parsing.html#create-an-element-for-the-token

This shrinks the standard library by about 60MiB, by my test.
This commit is contained in:
Michael Howell 2024-05-04 22:31:30 -07:00
parent 06e88c306a
commit eeb59f16a5
4 changed files with 48 additions and 26 deletions

View file

@ -4,7 +4,7 @@ javascript: false
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
// Since the javascript is disabled, there shouldn't be a toggle.
wait-for-css: (".sidebar", {"display": "none"})
assert-css: ("#sidebar-button", {"display": "none"})
assert-false: "#sidebar-button"
// Let's retry with javascript enabled.
javascript: true