perf: eliminate popover data duplication via DOM lookup#366
Draft
mikaello wants to merge 1 commit into
Draft
Conversation
Avrodoc Preview 🔍A live preview of the generated documentation is available at: This preview is built from the |
Instead of pre-rendering named_type_details HTML twice (once for the section and once for the popover JSON blob), popovers now read their content directly from the already-rendered section elements in the DOM. Changes: - Remove buildPopoverData() from static_content.js - Remove <script id="popover-data"> JSON blob from top_level.njk - Remove popover_title.njk (was only used by buildPopoverData) - Rewrite setupPopovers() in avrodoc.js to use findSection() + DOM queries for popover title (h2.namespace / h1.type-name) and content (.type-details innerHTML) - Wrap named_type.njk body in <div class="type-details"> so popovers can extract content without the heading elements This cuts per-type HTML cost from ~3.8 KB to ~2.6 KB (~50% reduction of the per-type overhead) and eliminates double-rendering at startup. Fixes: #361 (comment)
8c44c54 to
e63f280
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements performance optimization 1 from #361 (comment).
Previously,
named_type_detailsHTML was rendered twice per type at server startup:<section>elements<script id="popover-data" type="application/json">JSON blobThe JSON blob was then parsed at page load and used to populate Bootstrap popovers on hover.
Changes
buildPopoverData()fromstatic_content.js— no more double-rendering<script id="popover-data">fromtop_level.njkpopover_title.njk— was only used bybuildPopoverData()setupPopovers()inavrodoc.jsto usefindSection(href)and read popover title/content directly from the existing DOM elements:h2.namespace+h1.type-namein the section.type-detailsinnerHTML (new wrapper div innamed_type.njk)<div class="type-details">wrapper innamed_type.njkto allow clean content extraction without duplicating the heading elements in the popover bodyResult
popoverDataJSON parse on page load#/schema/<qualifiedName>), which were previously excluded from popover data