Menu

SVG animations in a GitHub README freeze on their first frame
📰

SVG animations in a GitHub README freeze on their first frame

DEV Community: github·Shay Manor·6 days ago
#iLPdh9KN
#devtogithub#technology#devto#dev#stats
Long article (376 words) — no AI summary yet.
Reading 0:00
15s threshold

I build gh-stats , a single SVG card for a GitHub profile README: a score out of 100, a contribution timeline, top collaborators, languages and commit streaks. One line of markdown, no signup.

For a while the score ring on that card was invisible on every profile that embedded it, and every test I had said it was fine. Here is why.

The bug

The ring animated in with SMIL:

<circle stroke-dasharray = "226.19" stroke-dashoffset = "26.23" > <animate attributeName = "stroke-dashoffset" from = "226.19" to = "26.23" dur = "1s" fill = "freeze" /> </circle>

Enter fullscreen mode

Exit fullscreen mode

GitHub renders README images through <img> , which puts the SVG in secure static mode. Animations don't run there. What gets painted is the animation's start value, not the element's static attribute. from="226.19" equals the full dash length, so the ring sat entirely out of view.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.