Skip to content

perf: eliminate popover data duplication via DOM lookup (~50% per-type size reduction)#365

Closed
mikaello wants to merge 0 commit into
migrate-phase2-ssrfrom
perf/eliminate-popover-duplication
Closed

perf: eliminate popover data duplication via DOM lookup (~50% per-type size reduction)#365
mikaello wants to merge 0 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 13, 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-365/

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

@mikaello mikaello force-pushed the perf/eliminate-popover-duplication branch from 11608a3 to 5646b18 Compare April 13, 2026 20:25
@mikaello mikaello changed the base branch from migrate-phase2-ssr to fix/cross-file-type-reference-order April 13, 2026 20:25
Base automatically changed from fix/cross-file-type-reference-order to migrate-phase2-ssr April 14, 2026 19:48
@mikaello mikaello force-pushed the perf/eliminate-popover-duplication branch from af2d48c to 5646b18 Compare April 14, 2026 19:49
@mikaello mikaello closed this Apr 14, 2026
@mikaello mikaello force-pushed the perf/eliminate-popover-duplication branch from 5646b18 to c222236 Compare April 14, 2026 19:50
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