Skip to content

perf: regenerate the analytics site to pick up non-blocking Chart.js and font loading (#3307) - #3310

Merged
frano-m merged 1 commit into
mainfrom
frano-m/3307-regenerate-analytics-page
Nov 13, 2026
Merged

frano-m merged 1 commit into
mainfrom
frano-m/3307-regenerate-analytics-page

Conversation

@frano-m

@frano-m frano-m commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Closes #3307

What changed

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

How to verify

Locally:

  1. Run cd analytics/site && python3 -m http.server 8080 and open http://localhost:8080.
  2. Check that the four charts render, that hovering a chart shows its tooltip, and that hovering a stat-card label (Users, User Sessions, Pageviews) shows its tooltip, which Escape closes.
  3. Click the ⓘ next to Engagement Rate. The help content opens; Escape closes it and returns focus to the button.
  4. Click a "Show all" toggle. It switches to "Show fewer" and back.

After merge, on the deployed page (GitHub Pages deploys analytics/site on push to main):
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/css2 stylesheet 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.html loads Chart.js with <script defer …>, and the Google Fonts stylesheet with media="print" onload="this.media='all'" plus a <noscript> fallback. Check lines 11–17 of the file, and step 5.
  • The deployed analytics page renders all charts, chart tooltips, stat-card tooltips and "Show all" toggles, with Inter once loaded. Check steps 5–6; steps 2–4 cover the same locally.

🤖 Generated with Claude Code
🐦 Built with cc-claude-tools

…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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 NoopDog left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. 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).

@frano-m frano-m changed the title perf: regenerate the analytics site to pick up non-blocking chart.js and font loading (#3307) perf: regenerate the analytics site to pick up non-blocking Chart.js and font loading (#3307) Nov 13, 2026
@frano-m

frano-m commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! Retitled with "Chart.js" capitalised, so the squash commit subject keeps the proper noun's casing.

@frano-m
frano-m merged commit b696f3b into main Nov 13, 2026
2 checks passed
@frano-m
frano-m deleted the frano-m/3307-regenerate-analytics-page branch November 13, 2026 05:34
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.

Regenerate the analytics site to pick up non-blocking chart.js and font loading

3 participants