Repository navigation
perf: regenerate the analytics site to pick up non-blocking Chart.js and font loading (#3307) - #3310
Conversation
…and font loading (#3307) Re-render `analytics/site/index.html` and `analytics/site/analytics.css` from the data-browser `analytics` package (main, 5.1.3) by calling its `write_page` with the HCA config from `analytics/generate_static_site.py`. The GA4 data in `analytics/site/data/` is unchanged (still May 2026). This brings in three upstream template changes: - data-browser #5026: Chart.js loads with `defer`, and Inter loads without blocking first paint (preconnect, media swap, noscript fallback) - data-browser #5024: stat-card tooltips and the engagement-rate toggletip use findable-ui 60's tooltip and toggletip patterns - data-browser #5021: findable-ui v60's `analytics.css` Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: cc-claude-tools <cc-claude-tools@clevercanary.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the analytics page’s resource-loading and tooltip updates.
No open issues 🎉
What changed in this PR
Regenerates the committed HCA Data Portal analytics page to pick up shared-template performance improvements for #3307. Analytics data and generation scripts remain unchanged.
Changes:
- Defers Chart.js and loads the Inter stylesheet asynchronously, with a fallback when JavaScript is disabled.
- Moves chart defaults and data loading to
DOMContentLoaded. - Updates to findable-ui v60 tooltip styles and adds an Engagement Rate toggletip with keyboard dismissal.
| File | Description |
|---|---|
analytics/site/index.html |
Updates resource loading, chart initialization, and stat-card help interactions. |
analytics/site/analytics.css |
Refreshes shared tooltip and toggletip styles, positioning, and usage documentation. |
Review effort: Balanced
NoopDog
left a comment
There was a problem hiding this comment.
Thanks, this does what #3307 asks. The committed analytics.css is byte-identical to the upstream template on data-browser main. index.html differs only in the six config substitutions from generate_static_site.py. defer on Chart.js, the async Inter stylesheet with preconnect, and the <noscript> fallback are all in place. Approving, with one optional point:
- Optional: consider writing "Chart.js" with its capital C in the title, since the title becomes the squash commit subject and the commit conventions keep a proper noun's casing:
perf: regenerate the analytics site to pick up non-blocking Chart.js and font loading (#3307).
|
Thanks! Retitled with "Chart.js" capitalised, so the squash commit subject keeps the proper noun's casing. |
Closes #3307
What changed
analytics/site/index.htmlandanalytics/site/analytics.cssfrom the data-browseranalyticspackage (main, version 5.1.3).<script defer …>, and the Inter stylesheet loads withpreconnectandmedia="print" onload="this.media='all'", plus a<noscript>fallback. The Chart.js defaults andloadData()now run onDOMContentLoaded.analytics.css.analytics/site/data/,analytics/generate_static_site.pyandanalytics/requirements.txtare unchanged.Why
The HCA Data Portal analytics page is a committed static site, so it only gets template changes when it is re-rendered. On the HCA Data Explorer page, DataBiosphere/data-browser#5011 measured first paint going from about 518 ms to about 362 ms on Fast 4G with the non-blocking Chart.js and font loading.
Assumptions I made
python generate_static_site.pywould also fetch GA4 data and needs GA4 credentials. Instead, the page was rendered with the package'swrite_page(config, output_dir), which writes onlyindex.htmlandanalytics.cssand makes no GA4 call. Theconfigpassed is the same dict thatmain()ingenerate_static_site.pypasses. The page therefore still shows May 2026, the same as fix: analytics page: render the header logo in html and load the released stylesheet (#3285) #3294.analytics.csstooltips working without:has(), and move the tooltip code that pages copy into findable-ui" (Keepanalytics.csstooltips working without:has(), and move the tooltip code that pages copy into findable-ui findable-ui#1236)How to verify
Locally:
cd analytics/site && python3 -m http.server 8080and open http://localhost:8080.After merge, on the deployed page (GitHub Pages deploys
analytics/siteon push tomain):5. Open the analytics page with DevTools' Network panel set to Fast 4G and Disable cache on. In the Performance panel, check that neither the Chart.js script nor the
fonts.googleapis.com/css2stylesheet is render-blocking.6. Repeat steps 2–4 on the deployed page and check that text switches to Inter once it loads.
Definition of done from #3307:
analytics/site/index.htmlloads Chart.js with<script defer …>, and the Google Fonts stylesheet withmedia="print" onload="this.media='all'"plus a<noscript>fallback. Check lines 11–17 of the file, and step 5.🤖 Generated with Claude Code
🐦 Built with cc-claude-tools