Nice things with SVG
82 comments
·April 12, 2025chrisweekly
jamra
Big fan of her book as well though I don’t know if the recommended tools are still relevant.
srid
Which book are you referring to?
technetist
Probably “SVG Animations” available through O’Reilly. It is from 2017. While many of the frameworks used have come and gone; there are a few stable concepts. If you can get it on sale, I’d recommend. Full price is a hard sell.
LegionMammal978
One fun thing that can be done with SVG files: you can use entities in an inline DTD to define constants to be shared across different places in the file. You can see some great examples of this in the SVGs in David Ellsworth's "Squares in Squares" page [0].
The major browsers have no issues with this, though note that some tools like Inkscape won't parse the DTD nor expand the entities.
[0] https://kingbird.myphotos.cc/packing/squares_in_squares.html
tannhaeuser
You say "entities" but that term is actually the name for SGML/XML's mechanism to define arbitrary syntactic content for reference/reuse with entity references a la &ref, whereas in SVG you can park shapes/paths/whatever under refs, giving those an id attribute value, and then <use> those element in the body SVG content, which is also what the page you linked is using (for each individual SVG ie. there's no sharing of rectangles across the many pictures since these are pulled-in individually via <embed> inot their own DOM rather than used as inline SVG).
I wonder why SVG's original designers found it necessary to supply an ad-hoc re-implementation of the entity mechanism. I think it might have to do with how rendering properties can be overridden at the usage site? At least I don't think it was established that browsers ignore entity definitions or basically anything in the document prolog/DOCTYPE considering SVG was part of W3C's push to replace HTML's SGMLish legacy syntax with XHTML/XML.
jarek-foksa
Entities seem to be resolved at parse time, so they are more like a preprocessor directives. <use> is much more powerful as all instances are "live" and updated dynamically when you change the original object.
If I recall correctly, the primary motivation behind <symbol> and <use> was interoperability with corresponding primitives in Adobe Illustrator.
lenkite
Maybe I am missing something, but can't find any !doctype or !element that would represent a DTD on that page. If you are talking simply about SVG defs and use - that isn't a DTD.
noahbald
It might work in browsers but a lot of SVG tooling will ignore DTD because it’s a DOS risk.
E.g. Billion laughs attack https://en.wikipedia.org/wiki/Billion_laughs_attack
timewizard
You can also extract different parts of an existing svg and use (clone) them elsewhere on the page.
https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/E...
ygra
I've used this to succinctly define a Sierpinski carpet on Wikimedia Commons a while ago: https://commons.wikimedia.org/wiki/File:Sierpinski_carpet_6....
That file was able to lock up or crash most SVG renderers back then.
znpy
That page took a good five seconds to render on my 2022 iPhone se
imhoguy
I really miss Macromedia Flash. There wasn't a single tech like Flash and SWF format which flourished with so many indie games and animated movies available without any extra downloads (other than Flash Player). Barier to entry was so low.
Now, take SVG, it has potential to do everything what SWF could. But there is no editor like Flash and scene/object based coding solution like ActionScript. And each browser has own quirks so only simple SVG is guaranteed to be displayed everywhere.
jefozabuss
I think web assembly can be comparable, e.g. unity/unreal/godot can compile to the browser pretty easily.
The problem is that each of these apps can be quite bloated and in the tens of MBs range not the usual single digit MB.
7952
Well it still exists as Adobe Animate which can export to html.
Comparing SVG to Flash seems like an apples to oranges comparison anyway. The format does not have to do everything that Flash did but can rely on the other technologies in the browser.
mettamage
Sounds like there is a startup opportunity here to recreate this
null
joshuaturner
"A Deep Dive Into SVG Path Commands" by Nanda Syahrasyad [0] is really great for understanding how SVG paths are composed. It's from almost 2 years ago now and really opened my eyes to all that SVGs can do and exactly how they're doing it.
baosoy
I worked on a project that did something fun with SVGs like this. It was built with React, and we had a series of still illustrations with an animated element, with its colour controlled by a CMS.
The frontend would basically call an API that would return an SVG image with the right colour assigned and the animation done by hiding and showing svg elements.
You can see an example here: https://web.archive.org/web/20221020133516im_/https://uncrow...
braebo
Complex animated SVG is fun to roll until you get into the weeds of SMIL and Safari bricks your phone for missing a leading 0 on a float or some random nonsense.
hansvm
"bricks"?
chrisweekly
It's slang; picture a literal brick (akin to a rock or stone). Your device is "bricked" if something has rendered it useless.
EE84M3i
I think GP is suggesting that the idea the GGP encountered an SVG that bricked their iPhone (without being a specifically crafted exploit payload) is an extraordinary claim that would require extraordinary evidence.
Voultapher
> Unkey's landing page is a nice example.
That landing page is a nauseatingly laggy experience on a very powerful M1 Pro laptop. And slow to load, all for some fancy lines? I'd take a product that focuses on substance over style as dev. Don't get me wrong, style is important and I like pretty things, but here it seems the tradeoff is not well done.
RobotToaster
Sounds like a problem with apple's implementation? I don't have any problem with firefox on an old 9th gen i5.
benjanik
For anyone who is using creatively using JS to create SVG dynamically and looking for work, DM me!
all2
Not that guy, but just chiming in so you have some visibility.
danielstocks
Made a small silly game recently just for fun, using mostly CSS animated SVG tiles for rendering: https://pipeline-panic.vercel.app/
two_handfuls
It's a fun little game, thank you for sharing!
perilunar
Nice!
rckt
SVG feels like a very underexplored and underused territory. You can do so many things with it. It really depends on your imagination. But you’ll possibly need to “hardcore” a lot of stuff, so yeah, depends on the use case as well.
geokon
It's a fun format that's easy to generate, but after trying to do complicated things with it.. you kind of understand why. It's underused b/c
- Complex graphics render different in different browsers. So you can't rely on it shows up the same (never had the same issue with a PDF for example)
- There are quite a few renderers but they typically don't implement large parts of SVG b/c it's too complex.. So you can never really be sure what parts are "safe" to use.
- Large complex graphics display extremely slowly (again, compared to a PDF)
- There is basically one editor.. Inkscape. And it's got it's own quirks and doesn't match Chrome/Firefox's behavior. Ex: You can add arrows to lines in Inkscape and they don't display in Firefox
It's also just got too many weird corner case limitations. For instance you can embed a SVG in another SVG (say to make a composite diagram). But you can't embed a SVG in to an SVG in to an SVG. On the web if you inline or link an SVG you also end up with different behaviors
Springtime
> There is basically one editor.. Inkscape.
Do you mean in terms of open source vector editors? As there a wide variety of tools with SVG authoring/editing capability, among the most well-known being Adobe Illustrator, Sketch, Affinity Photo/Designer, even some web apps are available that were made for online SVG editing (eg: SVGator).
Inkscape, like some tools such as Affinity's, adds its own XML namespace with custom attributes and values, though for arrows I would expect it to use native `marker` elements.
It's certainly true that with SVG's flexibility and particularly with cross-browser handling differences/bugs it can become its own task to get consistent presentation when doing more complex things with it. Still very fond of the format.
wwweston
Seems like it hits limits really fast — management/legibility gets difficult without groups and layers and performance doesn’t seem to scale well.
srid
without groups and layers
As distinct from `<g>`?perilunar
One thing i'd like to see is an entire site built with SVG and JS without any HTML at all. It's possible but i haven't seen anyone do it yet.
WillAdams
Two usages which I thought were interesting:
- adding toolpath information so as to use Flash as the engine for a Computer Aided Manufacturing tool: https://github.com/Jack000/PartKAM
- (this was my project along w/ Edward R. Ford) adding hyperlinks to part lists to highlight parts in an assembly diagram: https://github.com/shapeoko/Docs --- unfortunately, that doesn't seem to work anymore.
memhole
I agree. I’m sure there’s limitations, but svg feels more like a wysiwyg for web design than css
CliffStoll
Is there any SVG extension which allows density of line? I have a plotter which can lift/lower a pen; it's driven from SVG files. It'd be sweet to allow the pen to lower while the line is being drawn (as we often do with handwriting).
Oh - it's an Axidraw, from Evil Mad Scientist Labs - great device, wonderful people.
m-a-t-t-i
It's pretty easy to store custom instructions in plain SVG files and interpret them in with your reader. For example I have a multi-purpose laser-cutter / plotter and I use opacity for laser power, stroke weight for movement speed, green channel for number of passes, blue channel for z-axis height and red channel for lowering the pen or turning of the laser etc.
WillAdams
Probably you would want to do that with G-code.
I've been doing that sort of thing in:
defanor
SVG feels much like HTML to me, especially when animations are involved: on the first sight it is quite nice and simple, does its job well, can be handled by fairly basic viewers (as well as converters, editors) and generated easily. Then there are even more features with CSS and JS, which also look neat, but then simplicity goes away, along with it goes the wide support of full functionality, and compatibility (due to partial support, unexpected behaviors in different contexts). It still looks like a fine option when animations are needed, but I would rather avoid those in SVG when they are not necessary.
Even tho it's 8y old, Sarah Drasner's famous "SVG Can Do That?" talk is still eye-opening for many. CSS has matured a ton since then (I'm less sure about SVG per se)... in any case it's HIGHLY recommended.
Slides: https://slides.com/sdrasner/svg-can-do-that
Video: https://youtu.be/ADXX4fmWHbo?si=6YPZkopyEDc8PSte