Repository navigation
Conversation
Some API operation pages pass Googlebot's 2 MB HTML limit. Each API page is now rendered in memory and minified with WebMarkupMin 2.24.0 before it is written. The minifier keeps attribute quotes and optional end tags, which cost about 3%, so the markup stays as the views write it. WebMarkupMin treats `hidden` as a plain boolean and rewrites `hidden="until-found"` to `hidden`, which stops find in page from opening folded rows. `ApiHtmlMinifier` swaps that value for a stand-in attribute and back. A page the minifier reports errors on is written as rendered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4945/ |
The minifier cannot remove markup a row repeats on purpose. Each row printed its JSON path twice, in the permalink's `aria-label` and in the name's tooltip, and carried an icon `span`. The tooltip now reads the path from the `aria-label` in `tooltip.ts`, and CSS draws the icon on the anchor. With the minifier, 46 of 71 pages stay over 2 MB, down from 62. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| <code>@Model.Name</code> | ||
| } | ||
| @* The icon is drawn by CSS, and the name's path tooltip reads the path from this label, so a row prints it once. *@ | ||
| <a class="property-anchor" href="#@Model.AnchorId" aria-label="Link to @Model.PermalinkLabel" data-tippy-content="Copy link"></a> |
There was a problem hiding this comment.
Severity: P2 (Medium)
With NAVIGATION_PREVIEW on, removing span.property-anchor-icon here also removes the copy-link icon. Flag-on pages load only ds.css, and its Components/Pages/ApiReference/api-reference.css still draws the icon on .property-anchor-icon / .property-anchor-icon::after (around lines 1484–1530). Without that span, the anchor is empty and nothing styles it, so every property row on design-system API pages loses its visible permalink/copy control. Please port the ::after icon and hover/focus rules to a.property-anchor in api-reference.css too.
Generated by Libra. Specialist: libra-complexity. React with 👍 or 👎 to give feedback on this comment.
| generateStatistics: false | ||
| ); | ||
| if (result.Errors.Count == 0) | ||
| return result.MinifiedContent.Replace(UntilFoundStandIn, UntilFound, StringComparison.Ordinal); |
There was a problem hiding this comment.
Severity: P3 (Low)
The global replacement also rewrites literal data-api-hidden-until-found text in code samples, even when the original page has no hidden="until-found" attributes. That changes what readers see and copy. Restore only attributes that this pass actually substituted.
Generated by Libra. React with 👍 or 👎 to give feedback on this comment.
| var buffer = new MemoryStream(); | ||
| var position = Position; | ||
| Position = 0; | ||
| CopyTo(buffer); | ||
| Position = position; | ||
| return buffer.ToArray(); |
There was a problem hiding this comment.
Severity: P3 (Low)
Reading each page copies the full output into a second MemoryStream and then copies it again with ToArray(), just to decode it. These extra page-sized allocations add GC pressure when multi-megabyte pages render in parallel. Decode the written region of the original MemoryStream buffer instead.
Generated by Libra. React with 👍 or 👎 to give feedback on this comment.
| const href = icon | ||
| ?.closest<HTMLAnchorElement>('a.property-anchor') | ||
| ?.getAttribute('href') | ||
| const icon = e.target.closest<HTMLAnchorElement>('a.property-anchor') |
There was a problem hiding this comment.
Severity: P3 (Low)
Response-header links still put their tooltip on a child span, but the copy handler now flashes the anchor. Clicking a response-header link copies the URL without updating its tooltip to “Copied!”. Migrate the response-header markup too, or flash the child when one is present.
Generated by Libra. React with 👍 or 👎 to give feedback on this comment.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Do you also have build time measurements? |
yes, they are in the description, I'm investigating why it takes that much, and further improvements |
|
Closing: the stack #4952 → #4953 → #4955 → #4956 → #4959 replaces this. Its row changes are in #4956. #4959 uses a plain whitespace collapse instead of WebMarkupMin. That gets 46 pages over 2 MB against 41 here, without the extra ~55 s per build, the dependency, and the hidden="until-found" workaround (Taritsyn/WebMarkupMin#185). |
API Explorer pages now pass through WebMarkupMin before they are written, and each property row prints its JSON path once. API HTML is 11% smaller, and 25 of the 71 pages over Googlebot's 2 MB limit get under it. This replaces #4944: it takes over #4944's leaner rows, and the minifier replaces #4944's whitespace step.
Affects: API reference, Site UI
Prompt summary: Try an off-the-shelf .NET HTML minifier, WebMarkupMin, on the API pages in a separate PR from
main, and see what it does to page size and output. Then bring the leaner property rows over from #4944, so one PR has both. The goal behind it is elastic/docs-eng-team#1183: bring API pages under Googlebot's 2 MB HTML limit.Why
Googlebot reads only the first 2 MB of an HTML page. With today's specs, 71 API operation pages are over that limit. Most of their bytes are markup: indentation a browser ignores, and a row partial that repeats thousands of times. Each row prints its JSON path twice and carries an icon
span.What
Every API page is minified before it is written
OpenApiGeneratorrenders each page into memory, andApiHtmlMinifierminifies it with WebMarkupMin 2.24.0 before writing the file. The minifier removes whitespace between elements, comments, and redundant attributes, and it trims embedded CSS and JS. It keeps attribute quotes and optional end tags. Removing those would save about 3% more, but it makes the markup differ from what the views write and breaks 18 tests that match it. If the minifier reports an error, the page is written as rendered and a warning is logged.hidden="until-found"survivesWebMarkupMin treats
hiddenas a plain boolean, so it rewriteshidden="until-found"tohiddenorhidden=hidden. Find in page then stops opening folded rows, and the CSS fallback for[hidden='until-found']stops matching.ApiHtmlMinifierswaps that value for a stand-in attribute before minifying and restores it afterwards. A unit test fails without the swap. The bug is reported upstream as Taritsyn/WebMarkupMin#185, and the swap goes once a fixed version ships.A property row prints its path once
The permalink keeps the full path in its
aria-label, so screen readers still announcequery.bool.must[].match. The name's mono tooltip now reads the path from that label (tooltip.ts) and no longer carries its owndata-tippy-contentanddata-tippy-theme. A top-level field still shows no tooltip. A minifier can't remove this duplicate, because both copies are real attribute values.The link icon is the anchor
CSS now draws the copy-link icon as the anchor's
::after, which replaces thespan.property-anchor-iconin every row. The "Copy link" tooltip, the copy-on-click and the hover and focus states move to thea.property-anchoritself.Results
From an isolated build of
docs/with the AOT binary, compared withmain:mainindices-createsimulate-ingestget-dashboardmainagainst 112 s with the minifier; a later run on a slower network measured 87 s against 155 s. I have not profiled where that time goes.Out of scope: the 46 pages still over 2 MB: the Elasticsearch template and
simulate-ingestpages, and the Kibana dashboard and visualization pages. They need the content changes listed on elastic/docs-eng-team#1183. Theapi-explorerbrowser journey needs an assembler build, so it was not run.Verify
Build the docs and count the pages over 2 MB:
Check on the preview
settings.analysis.analyzerfor its path tooltip. Hover the row for the link icon and click it to copy the link. Use find in page on a folded field such askuromoji_iteration_mark; its row should open.or.🤖 Generated with Claude Code