Skip to content

Load diagram fallbacks only without JavaScript - #196

Merged
marcduiker merged 1 commit into
masterfrom
diagram-fallbacks-noscript
Oct 26, 2026
Merged

marcduiker merged 1 commit into
masterfrom
diagram-fallbacks-noscript

Conversation

@marcduiker

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #195. The fix below was pushed to #195's branch after that PR had been merged, so it never reached master.

Every homepage diagram's static fallback was an <image> inside its svg. Every visitor downloaded all six fallbacks, about 165 KB, even though the scripts draw over them straight away.

What changes

  • Fallbacks: each one is now an <img> in a <noscript> next to its svg, laid over the svg's box by CSS. This covers the hero and all five 2D diagrams.
    • Browsers running the scripts never fetch them.
    • Without JavaScript, they show as before.
  • Scripts: hero-diagram.js and diagrams.js no longer remove a fallback, and the fallback exporter no longer strips one.
  • Regenerated fallbacks:
  • Skill: it explains why the fallback stays in its <noscript>.

Homepage download, measured locally in Chrome

Before After
With JavaScript, uncompressed 937 KB 772 KB
With JavaScript, text compressed as Netlify serves it ~541 KB ~498 KB
Fallback images fetched with JavaScript 6 0

Tests

  • With JavaScript: the hero and the 2D diagrams never request their fallbacks.
  • Without JavaScript: each fallback is visible, loads, and sits over its svg's box, to within a pixel.
  • Still-diagram test: its HTML rewrite allows for the <noscript> before the pause button.

Test plan

  • Full Playwright suite on this exact tree: 223 passed, 9 skipped. One spec timed out during browser setup under parallel load and passed on rerun (7/7).
  • Network check: no fallback requests with JavaScript; all six load without it.
  • CI on the pinned Hugo 0.147.9

🤖 Generated with Claude Code

Every diagram's static fallback was an <image> inside its svg, so every
visitor downloaded all six (about 165 KB) although the scripts draw over
them straight away. Each fallback is now an <img> in a <noscript> next
to its svg, laid over the svg's box by CSS, for the hero and all 2D
diagrams. Browsers running the scripts never fetch them; without
JavaScript they show as before.

Homepage download with JavaScript, measured locally: 937 KB to 772 KB
uncompressed, about 541 KB to 498 KB with text compressed.

- The scripts no longer remove a fallback, and the exporter no longer
  strips one from its copy.
- Tests: with JavaScript, the hero and the 2D diagrams never request
  their fallbacks; without it, each fallback is visible, loads, and
  sits over its svg's box. The still-diagram test's HTML rewrite allows
  for the noscript before the pause button.
- The regenerated fallbacks lose a blank line, and apis.svg picks up the
  reworded alpha sentence from #195, which was merged without it.
- The skill explains why the fallback stays in its noscript.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Marc Duiker <4191277+marcduiker@users.noreply.github.com>
@marcduiker
marcduiker merged commit b63be76 into master Oct 26, 2026
6 checks passed
@marcduiker
marcduiker deleted the diagram-fallbacks-noscript branch October 26, 2026 12:07
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