Skip to content

perf: eliminate popover data duplication via DOM lookup#366

Draft
mikaello wants to merge 1 commit into
migrate-phase2-ssrfrom
perf/eliminate-popover-duplication
Draft

perf: eliminate popover data duplication via DOM lookup#366
mikaello wants to merge 1 commit into
migrate-phase2-ssrfrom
perf/eliminate-popover-duplication

Conversation

@mikaello

Copy link
Copy Markdown
Owner

Summary

Implements performance optimization 1 from #361 (comment).

Previously, named_type_details HTML was rendered twice per type at server startup:

  1. Once into the hidden <section> elements
  2. Again into a <script id="popover-data" type="application/json"> JSON blob

The JSON blob was then parsed at page load and used to populate Bootstrap popovers on hover.

Changes

  • Remove buildPopoverData() from static_content.js — no more double-rendering
  • Remove <script id="popover-data"> from top_level.njk
  • Remove popover_title.njk — was only used by buildPopoverData()
  • Rewrite setupPopovers() in avrodoc.js to use findSection(href) and read popover title/content directly from the existing DOM elements:
    • Title: extracted from h2.namespace + h1.type-name in the section
    • Content: .type-details innerHTML (new wrapper div in named_type.njk)
  • Add <div class="type-details"> wrapper in named_type.njk to allow clean content extraction without duplicating the heading elements in the popover body

Result

  • Per-type HTML cost: ~3.8 KB → ~2.6 KB (~32% reduction per type)
  • At 1000 types: ~4 MB → ~2.6 MB
  • At 5000 types: ~19 MB → ~13 MB
  • Eliminates the popoverData JSON parse on page load
  • Popovers now work for all navigable types including shared types (#/schema/<qualifiedName>), which were previously excluded from popover data

@github-actions

github-actions Bot commented Apr 14, 2026

Copy link
Copy Markdown

Avrodoc Preview 🔍

A live preview of the generated documentation is available at:
👉 https://mikaello.github.io/avrodoc-plus/pr-preview/pr-366/

This preview is built from the schemata/ directory and updates on every push to this PR.

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)
@mikaello mikaello force-pushed the perf/eliminate-popover-duplication branch from 8c44c54 to e63f280 Compare April 14, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant