TIL you can make "GIFs" with SVGs for GitHub README.md files
87 comments
·July 8, 2025unleaded
johnisgood
I like https://upload.wikimedia.org/wikipedia/commons/1/13/London_U.... It shows step-free areas for wheelchair users. It is pretty useful to me.
As for the first link, I immediately had to come up with a way to click on the warheads programmatically. I saved the world! :D
leonidasv
SVG started as an open competitor to Shockwave/Flash Player and also an application format for PDAs. It almost got networking support once.
bawolff
> It almost got networking support once.
SVG support full javascript. It has networking support.
(In web browsers the <img> tag allows only restricted subset, butbyou get the full thing with iframe)
echelon
Too bad nothing has ever come close to replacing the SWF format.
You could pack so much into a single binary distributable media file. Games, videos, websites, infographics, tools, chat rooms.
SWF was brilliant and it should have thrived.
qwertox
If it weren't for Adobe's crappy support of the player, I would agree, but they did much more harm than good with it. It was a massive attack surface and they didn't care about closing their zero-day drive-by exploits in a sensible timeframe.
Also they were basically the founders of persistent fingerprinting via Flash cookies.
So no, thank you, I'm more than happy it didn't thrive more than it already did.
unleaded
absolutely. really is strange that you used to be able to download a music video in less than 2-3mb with lossless video quality, but now that's not really a thing anymore. I feel like if Adobe didn't get greedy and encourage its use for absolutely everything (and/or web standards got up to speed faster) people wouldn't wouldn't approach talking about Flash with the 10-foot pole they often do today (as a platform—not how everyone talks about how much they loved flash games)
ToucanLoucan
Thank fuck it didn't. I can't fathom how quickly the obnoxious advertiser industrial complex would've grabbed hold of that and invented whole new genres of shoving products in our collective face.
koakuma-chan
Huh? SVG stands for scalable vector graphics.
FateOfNations
Functionally, it can do a lot of the same things as SWF/Flash. Can do animations (see article) and it's scriptable using JavaScript for interactivity.
tiagod
And JavaScript starts with Java. Naming is hard.
lilyball
That first link doesn't work in Safari, and I'm really wondering what's missing. Clicking the button works, but clicking the warheads does nothing. I also don't get the crosshairs cursors that I see when I try this in Firefox.
Theodores
That checkbox feature in the Tube Map is awesome. I need to up my SVG game.
Bookmarked!
taeric
Try clicking on a line's name in the key. Very impressive map.
Natsu
After reading the headline and before reading the article, I thought it'd be something like a visual hash of readme files, as an easy way to see if anything had changed between releases.
I was thinking that might be a useful thing for people to spot when a ToS, EULA, etc. changed since those are long documents that frequently get sneaky revisions.
blackant
I have an animated SVG on my README that is rebuilt once a day to include the weather and day of the week. Built during jury duty a few years ago :P https://github.com/jasonlong
paulirish
If the target is a GitHub readme, then you can embed a video directly. eg https://github.com/paulirish/git-recent#readme
That said, OP's SVG trick may be a smarter choice if the content is a terminal capture.
c-hendricks
If you're going this route of adding a straight up video (which isn't bad!) it helps to edit the readme directly on GitHub. That way they're uploaded to githubusercontent (or whatever the domain is) and not taking up space in your repository.
hbn
Were people doing that other option?
The idea of committing a video to your repository for a PR seems silly. Every PR adds a new video to the codebase? Do you make a PR to prune them every once in a while?
aziaziazi
> Every PR adds a new video to the codebase
Git commits only differences with the precedent commit, not the entire repository. Therefore the video is only committed once as long as that video doesn’t change.
pamelafox
The nice thing about videos is the play/pause/slider UI. Some platforms do add play/pause explicitly to GIFs, using some JS, but as far as I know (and you would know more), that's not built into browsers yet. That's been one of the reasons I often end up using videos instead.
When I've personally animated SVGs for use in RevealJS presentations, I tend to use CSS animations that I could control with JS if I wanted.
not2b
An animated GIF is essentially a video with a large number of restrictions and poor compression compared to an actual video. Often sites convert animated GIFs to videos because the result is smaller and works better.
kzrdude
If this gets widespread use, browsers will catch up and in 5-10 years we will have pause buttons! ;)
justsomehnguy
Meanwhile we are still have a stupid overlay controls because 20 years ago it was an iframe for an ActiveX control.
pcthrowaway
The SVG trick is less usable for screen captures IMO, since you lose controls.
I think it's best for embedding a motion demo of a feature your software provides, no more than 5 seconds. Even then, a video option may be useful to some people.
yawnxyz
It's pretty unintuitive that you can just copy text straight from an animation, but that's the neatest part of this!
ndr
What would be wild is if the animation pauses on mouse-over.
It's quite a challenge for copy-paste to be useful when the terminal is scrolling.
null
sheepybloke
Also looks like this is supported in Gitlab as well!
Example from the Mariner repo[1] after doing a quick google and finding a link to the site.
[1] https://gitlab.com/radek-sprta/mariner/blob/master/README.md
xml
A word of caution: There are SVGs which can freeze a page, so make sure that you do not link to any third party SVGs. This is a known bug, but both the Google Chrome and Mozilla team do not want to fix it.
Here is an evil example SVG for demonstration.
DON'T CLICK THIS LINK UNLESS YOU WANT TO RISK CRASHING YOUR BROWSER!
pcthrowaway
Wait so are recursive XXE attacks like (I'm assuming) this one possible on Github READMEs? Or have they somehow mitigated them?
mmis1000
Crash a single page or even the whole browser isn't really a security problem though. In fact, there are so many ways to freeze the whole tab or even browser ui with build-in function if you apply it way too many times. (For example, a long chain of blur filters will make the chrome ui non responsive because the render time will skyrocket.)
Although if the affect area does escape the tab, the issue will have higher priority because that would be annoying to user.
pjc50
"SVG is inherently animated" is new to me, and now I'm going to spend my time on the bus thinking what might be done with that. Does it support infinite loop?
snackbroken
> Does it support infinite loop?
Yes, by setting the repeatCount or repeatDur attribute of the <animate> tag to "indefinite". Notably, since <animation> tags effect individual attributes and not the image as a whole, different parts of the image can be on different animation cycles and don't have to add up to some small common multiple.
abirch
Yes
https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/E...
<svg viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg">
<rect width="10" height="10">
<animate
attributeName="rx"
values="0;5;0"
dur="10s"
repeatCount="indefinite" />
</rect>
</svg>
jerf
SVG embeds Ecmascript (or Javascript as the rest of the world knows it): https://www.w3.org/TR/SVG11/script.html
So not only do you get all the animation support from the attributes, you can fill in anything you need from scripting.
Jtsummers
> Does it support infinite loop?
Yes it does.
https://www.w3schools.com/graphics/svg_animation.asp - Has some examples, you may need to refresh to see some of them (ones that don't repeat) in action as you scroll down the page.
exabrial
I freakin love SVG. Someday I hope we just end up with a browser standard:
* pluggable execution engine/memory model (WASM, JVM, CLR, etc)
* SVG output (binary or text)
From there, the developer can choose whatever model he wants to display a "page", no longer be limited to the Document Object Model.
lpghatguy
Once upon a time, Flash, Java, Silverlight, ActiveX, etc. ruled the web.
I think the world is _much_ better off today, with a common language and platform. I don't think those big third party runtimes could survive in the browser in today's threat environment.
viraptor
For some sick reason now I really want to convert some SVG architecture diagrams to movies which reveal the nodes in a dramatic anime battle style with zoom-ins, freeze frames, pulsating lines around, etc.
x187463
Well, this is cool. I'll have to see how it handles the sorts of effects I show in the README at https://github.com/ChrisBuilds/terminaltexteffects. I don't know much about SVG but anything that attempts to actually store the text is going to create a very large amount of data. I'll try it for fun.
matths
I like little TIL posts like this, introducing new tools and sharing first-hand experiences with them. Working around restrictions (like using animations in Github Markdown) leads to this kind of creative stuff. I looked at the resulting SVG https://koaning.io/posts/svg-gifs/parrot.svg and realised that a lot of inline SVG elements are used within inline SVG within..the SVG. I've never seen that before. So thank you very much for sharing.
Aardwolf
So one could make a quine: an animated SVG that shows its own source code being typed into a text editor
firefax
there's also an apng standard that almost noone makes use of despite not being patent uncumbered like gif is and it does a good job compressing more "pixel art" or line drawings in the way gif does. (tends to be a bit less efficient with actual photographs)
You can do a lot of impressive things with SVGs. Some examples from Wikipedia (no JS in any)
https://upload.wikimedia.org/wikipedia/commons/9/9b/SMIL_mis... missile command clone
https://upload.wikimedia.org/wikipedia/commons/1/13/London_U... tube map
https://upload.wikimedia.org/wikipedia/commons/4/49/Rolling_... rolling shutter animation