7 ms·
Regular reminder that icon fonts are bad for accessibility and are technically troublesome also in other ways: https://github.blog/2016-02-22-delivering-octicon
by TonyTrapp 6y ago
Regular reminder that icon fonts are bad for accessibility and are technically troublesome also in other ways: https://github.blog/2016-02-22-delivering-octicons-with-svg/ https://github.blog/2016-02-22-delivering-octicons-with-svg/
- petters 6y agoWhen developing, the fact that icon fonts follow the size and color of the surrounding text is nice, though. E.g. when tweaking the text color of a button. At least in my limited frontend experience.
- DangerousPie 6y agoSVGs can do the same thing.
- tobyhinloopen 6y agoThat SVG does have to be inline though, which drastically increases your HTML page’s size. You cannot style an SVG loaded in an IMG element. Imagine rendering 50 rows with each 6 icons, 1kb each. There are 6 unique icons, so it’s only 6kb each loading them from the server, but inline you’ll have 300kb of SVG icons
- DangerousPie 6y agoYou can use an "SVG sprite" with <use>. No need to inline the SVG every time.
- tobyhinloopen 6y agoOh? I have to look that up
- DangerousPie 6y agoTook me a while to figure it all out, but it works surprisingly well. I have been using https://icomoon.io/ https://icomoon.io/ to generate the sprites. They also provide a JS polyfill to support IE.
- faeyanpiraat 6y agoBut how do you actually apply the styling? Just add a class to the <use> tag which contains “color:red;” ?
- jarek-foksa 6y agoThis should work as long as the SVG shapes have the "fill" and/or "stroke" set to "currentColor".
- 8lall0 6y agoYou can export your SVGs with fill="currentColor" and your color attribute onto the SVG tag or its container would work. Since at $JOB i'm using SVG icons with more than one color, i use fill="var(--svg-color-base)" or fill="var(--svg-color-accent)" so i can precisely set which color i want, in a perfectly scope-able manner. The greatest advantage is that you can reference externally your svg with xlink.href on top of your website: you have to make one more request, but it's cacheable. Pick your tradeoff :)
- nikkwong 6y agoYou're saying you can embed all the SVGs onto one page, and then reference them on other pages/domains by using xlink.href? I haven't heard of this? So what you're describing is having site.com/page1 which has markup: <body> <svg id="icon-1"> ... </svg> </body> and then on site.com/page2 having <body> <svg> <use href="/page1#icon-1"> </svg> </body> Or something of this manner? Haven't encountered this, but sounds awesome; especially since you'd get the power of both inlining and caching the asset.
- f-word 6y ago
- Mauricebranagh 6y agocompared to the massive Js CSS and Images included on almost all 99.9% of pages a bit of SVG is trivial.
- d0gbread 6y agoEverything's a bit in isolation, that's how they get ya. Easily to bulk up, hard to trim back down.
- Mauricebranagh 6y agosigh tell me about it
- Aeolun 6y ago1kb is a lot for a simple svg icon. That said, if you have a single page app already, you can render as many icons as you want, since you’ll only download them once anyway.
- kps 6y agoBut if you want 5 icons, 5K of SVG beats 55K of WOFF.
- tobyhinloopen 6y agoI wonder how React copes with a whole bunch of inline SVGs. Seems expensive
- RobertKerans 6y agoCopes totally fine and it's trivial to memoise them anyway.
- duhi88 6y agoMost icons are generally tiny. Millage will vary, but they can speed up your site. Fewer requests for a slightly large page size.
- petters 6y agoThanks for the clarification. Clearly, I have things to learn about SVGs.
- nagisa 6y agoTo illustrate an issue this article describes, https://i.imgur.com/TzMXgUd.png https://i.imgur.com/TzMXgUd.png is what the linked page looks like with a forced/limited font selection on Firefox.
- Tagbert 6y agoIf you block fonts, this is not a surprise. Using a fresh in stall of Firefox, the linked page displays the icons correctly.
- forgotmypw17 6y agothat,s the point. not everyone WANTS to load them or CAN load/see them.
- deleted 6y ago[deleted]
- bagacrap 6y agoI can't see how these would be bad for accessibility. The markup is a<span> with a human readable word like "home" in it.
- Kaze404 6y agohttps://github.blog/2016-02-22-delivering-octicons-with-svg/#accessibility https://github.blog/2016-02-22-delivering-octicons-with-svg/...
- TonyTrapp 6y agoRaw icon names (that you cannot influence) often don't make a good replacement for proper alt text. Quite often they should not be read out at all. Furthermore, people forcing websites to use a font like OpenDyslexic will see these non-descriptive icon names instead of the real icons.
- senux 6y agoJust to complement other's responses, accessibility is a spectrum. We ought to believe someone chooses to use an icon for aesthetics AND usability reasons. If the icon can't be rendered at all, it defeats it's purpose despite it having a "description". Ultimately, if a well designed, user-friendly system doesn't work the way it's intended to, it is an accessibility issue of some degree. Albeit, some times more trivial than others.
- greggturkington 6y agoThe content "trending_up" is almost useless, a voiceover will not interpret the underscore as a space. There are no ARIA attributes that link any of the text to the buttons.
- deleted 6y ago[deleted]
- benrbray 6y agoIt seems like the solution is to improve the accessibility tools. The information is all already there.
- ChrisArchitect 6y ago(2016)? How about not using an ancient article to make a claim about a fast changing space like web dev?
- TonyTrapp 6y agoEvery single reasons for switching away from icon fonts mentioned in that article is still valid. Icon fonts were already a bad idea in 2016, and they still are a bad idea in 2021.
- lpage 6y agoThe SVGs used to generate the icon fonts are Apache 2.0 licensed: https://github.com/google/material-design-icons/tree/master/src https://github.com/google/material-design-icons/tree/master/....
- Solvitieg 6y agoSo is Javascript but that hasn't stopped anybody
- forgotmypw17 6y agonot true. many design their sites THOUGHTFULLY and as a result they can be accessed without js. case in point: site i,m writing this comment on. counterpoint: almost anything on google.com domain these days.