<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Philipp Trommler's Blog - svg</title><link href="https://blog.philipp-trommler.me/en/" rel="alternate"></link><link href="https://blog.philipp-trommler.me/en/feeds/tag-svg.atom.xml" rel="self"></link><id>https://blog.philipp-trommler.me/en/</id><updated>2019-11-27T14:53:00+01:00</updated><entry><title>Tiny Bits: SVG icons</title><link href="https://blog.philipp-trommler.me/en/posts/2019/08/31/tb-svg-icons/" rel="alternate"></link><published>2019-08-31T23:50:00+02:00</published><updated>2019-11-27T14:53:00+01:00</updated><author><name>Philipp Trommler</name></author><id>tag:blog.philipp-trommler.me,2019-08-31:/en/posts/2019/08/31/tb-svg-icons/</id><summary type="html">&lt;p&gt;Tiny Bits is (hopefully) going to be a more or less regular series of
posts about small ideas, actions or changes, that are important
regardless of their size. This time: SVG icons for my curriculum vitae
website.&lt;/p&gt;</summary><content type="html">&lt;div class="toc"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#initial-situation"&gt;Initial situation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#the-solution"&gt;The solution&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#outcome"&gt;Outcome&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;h3 id="initial-situation"&gt;Initial situation&lt;a class="headerlink" href="#initial-situation" title="Permanent link"&gt;&amp;para;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;My &lt;a href="https://cv.philipp-trommler.me/"&gt;curriculum vitae website&lt;/a&gt; used the two
&lt;a href="https://fontawesome.com/"&gt;Font Awesome&lt;/a&gt; free fonts "solid" and "brands" to
display four icons (for location, Github, e-mail address and a link to this
blog) right at the top. I think this is a nice way to give recruiters the most
important links at a quick glimpse, which is why I've taken this over from the
LaTeX CV that the website is based on. Alas, this has made the site not exactly
smaller.&lt;/p&gt;
&lt;p&gt;Of course, my CV site wasn't that remarkable in terms of modern web design, but
bearing in mind that I'm always striving for efficiency and minimalism, the
state could not be tolerated any longer. In addition, my privacy paranoia
emerged in this context, too: Since I don't use Font Awesome's CDN (or any
other) in order to prevent my visitors from being tracked and because my site is
usually viewed once –&amp;nbsp;thus always for the first time –, browser caching
could not reduce the problem.&lt;/p&gt;
&lt;figure&gt;
    &lt;img alt="A pie chart showing the percentual shares of different parts of my 
CV website. HTML, CSS and the profile picture have a share of 96.02 KB 
(29.7 %), the Raleway font 81.41 KB (25.2 %) and Font Awesome 145.94 KB 
(45.1 %)."
         src="https://blog.philipp-trommler.me/en/images/2019/tb-svg-icons-pageweight-before.png" /&gt;
    &lt;figcaption&gt;The pageweight before switching to SVG icons in terms of
transmitted bytes. The web fonts are taking up nearly three fourths of the size
with Font Awesome alone weighing in nearly the half, just for four
icons. Note that the weight of the profile picture depends on the visitor's
display resolution.&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;Speaking about the hard numbers, web fonts made up nearly three fourths of the
transmitted bytes for my visitors (227.35&amp;nbsp;KB, 70.3&amp;nbsp;%), with Font
Awesome alone taking nearly half of the page weight. (145.94&amp;nbsp;KB,
45.1&amp;nbsp;%). This was just as horrible as it sounds, all that for just four
icons.&lt;/p&gt;
&lt;p&gt;You may ask how it could come to this situation. Well, I was (and still am
*cough*) in a phase of a "professional re-orientation" and the site just had
to be finished. Styling a HR-facing website just as this one here was no option
and I knew that I would come back later and clean up the mess that I left. I
hope this is an adequate excuse 😉.&lt;/p&gt;
&lt;h3 id="the-solution"&gt;The solution&lt;a class="headerlink" href="#the-solution" title="Permanent link"&gt;&amp;para;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Of course the solution is plain SVG icons. Why should you include multiple web
fonts containing hundreds of icons when you could instead only include exactly
those four icons that you need? Thus, I've taken a look for available icons
fitting my needs.&lt;/p&gt;
&lt;p&gt;I've found the &lt;a href="https://github.com/edent/SuperTinyIcons"&gt;SuperTinyIcons&lt;/a&gt; which
hold what they promise with their name. Each and every icon is under 1&amp;nbsp;KB
giving me a theoretic size reduction of about 97&amp;nbsp;%. Additionally, the
README claims that the size can be reduced even further by removing round edges
and the background in its entirety, which I'd have to do anyway.&lt;/p&gt;
&lt;p&gt;Sadly, they don't really match the look of the Font Awesome icons that I used
before and that I still use for my LaTeX CV. Since I want both the PDF and the
website to look as identically as feasible and adding SuperTinyIcons to LaTeX
seemed not like an option, using these icons was not possible. Luckily,
Font Awesome is an Open Source font and you can find the SVGs it's based on &lt;a href="https://github.com/FortAwesome/Font-Awesome"&gt;on
Github&lt;/a&gt;. So I decided to stay with
the same icons I've used before even if that means a bit larger file sizes. I
mean, in the end it will still be &lt;em&gt;much&lt;/em&gt; smaller than before.&lt;/p&gt;
&lt;p&gt;From here on it's quite simple: Download the icons you use, open them in
&lt;a href="https://inkscape.org/"&gt;Inkscape&lt;/a&gt; and set the canvas size to 512 times 512
pixels. I've decided to scale the icons down to 50&amp;nbsp;% because the icon font
was "scaled down", as well, which was probably the only tricky part. If you use
Inkscape's built-in scale function, it'll add a &lt;code&gt;style="scale:50%"&lt;/code&gt; to the path
element of the SVG, but this seems to be ignored by the browser (at least by
Firefox). Instead you'll have to use the width and height inputs at the top of
Inkscape's window and manually re-center the path afterwards (don't forget to
hit the lock icon in order to ensure proportional scaling).&lt;/p&gt;
&lt;p&gt;With everything set up correctly in Inkscape, save the SVG and open it up in
your favorite text editor (we all know that it's vim 😜) because we need to get
rid off a lot of –&amp;nbsp;for our use case –&amp;nbsp;unnecessary meta data that
Inkscape has put into the SVG. What you see will probably be something like
this:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;table class="codehilitetable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt; 1&lt;/span&gt;
&lt;span class="normal"&gt; 2&lt;/span&gt;
&lt;span class="normal"&gt; 3&lt;/span&gt;
&lt;span class="normal"&gt; 4&lt;/span&gt;
&lt;span class="normal"&gt; 5&lt;/span&gt;
&lt;span class="normal"&gt; 6&lt;/span&gt;
&lt;span class="normal"&gt; 7&lt;/span&gt;
&lt;span class="normal"&gt; 8&lt;/span&gt;
&lt;span class="normal"&gt; 9&lt;/span&gt;
&lt;span class="normal"&gt;10&lt;/span&gt;
&lt;span class="normal"&gt;11&lt;/span&gt;
&lt;span class="normal"&gt;12&lt;/span&gt;
&lt;span class="normal"&gt;13&lt;/span&gt;
&lt;span class="normal"&gt;14&lt;/span&gt;
&lt;span class="normal"&gt;15&lt;/span&gt;
&lt;span class="normal"&gt;16&lt;/span&gt;
&lt;span class="normal"&gt;17&lt;/span&gt;
&lt;span class="normal"&gt;18&lt;/span&gt;
&lt;span class="normal"&gt;19&lt;/span&gt;
&lt;span class="normal"&gt;20&lt;/span&gt;
&lt;span class="normal"&gt;21&lt;/span&gt;
&lt;span class="normal"&gt;22&lt;/span&gt;
&lt;span class="normal"&gt;23&lt;/span&gt;
&lt;span class="normal"&gt;24&lt;/span&gt;
&lt;span class="normal"&gt;25&lt;/span&gt;
&lt;span class="normal"&gt;26&lt;/span&gt;
&lt;span class="normal"&gt;27&lt;/span&gt;
&lt;span class="normal"&gt;28&lt;/span&gt;
&lt;span class="normal"&gt;29&lt;/span&gt;
&lt;span class="normal"&gt;30&lt;/span&gt;
&lt;span class="normal"&gt;31&lt;/span&gt;
&lt;span class="normal"&gt;32&lt;/span&gt;
&lt;span class="normal"&gt;33&lt;/span&gt;
&lt;span class="normal"&gt;34&lt;/span&gt;
&lt;span class="normal"&gt;35&lt;/span&gt;
&lt;span class="normal"&gt;36&lt;/span&gt;
&lt;span class="normal"&gt;37&lt;/span&gt;
&lt;span class="normal"&gt;38&lt;/span&gt;
&lt;span class="normal"&gt;39&lt;/span&gt;
&lt;span class="normal"&gt;40&lt;/span&gt;
&lt;span class="normal"&gt;41&lt;/span&gt;
&lt;span class="normal"&gt;42&lt;/span&gt;
&lt;span class="normal"&gt;43&lt;/span&gt;
&lt;span class="normal"&gt;44&lt;/span&gt;
&lt;span class="normal"&gt;45&lt;/span&gt;
&lt;span class="normal"&gt;46&lt;/span&gt;
&lt;span class="normal"&gt;47&lt;/span&gt;
&lt;span class="normal"&gt;48&lt;/span&gt;
&lt;span class="normal"&gt;49&lt;/span&gt;
&lt;span class="normal"&gt;50&lt;/span&gt;
&lt;span class="normal"&gt;51&lt;/span&gt;
&lt;span class="normal"&gt;52&lt;/span&gt;
&lt;span class="normal"&gt;53&lt;/span&gt;
&lt;span class="normal"&gt;54&lt;/span&gt;
&lt;span class="normal"&gt;55&lt;/span&gt;
&lt;span class="normal"&gt;56&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;svg&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="na"&gt;xmlns:dc=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="na"&gt;xmlns:cc=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;http://creativecommons.org/ns#&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="na"&gt;xmlns:rdf=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="na"&gt;xmlns:svg=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;http://www.w3.org/2000/svg&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="na"&gt;xmlns=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;http://www.w3.org/2000/svg&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="na"&gt;xmlns:sodipodi=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="na"&gt;xmlns:inkscape=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;http://www.inkscape.org/namespaces/inkscape&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="na"&gt;viewBox=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;0 0 512 512&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="na"&gt;version=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;1.1&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;svg841&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="na"&gt;sodipodi:docname=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;rss.svg&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="na"&gt;width=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;512&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="na"&gt;height=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;512&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="na"&gt;inkscape:version=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;0.92.3 (2405546, 2018-03-11)&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;metadata&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;metadata847&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;rdf:RDF&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;cc:Work&lt;/span&gt;
&lt;span class="w"&gt;         &lt;/span&gt;&lt;span class="na"&gt;rdf:about=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;dc:format&amp;gt;&lt;/span&gt;image/svg+xml&lt;span class="nt"&gt;&amp;lt;/dc:format&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;dc:type&lt;/span&gt;
&lt;span class="w"&gt;           &lt;/span&gt;&lt;span class="na"&gt;rdf:resource=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;http://purl.org/dc/dcmitype/StillImage&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;dc:title&amp;gt;&amp;lt;/dc:title&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;/cc:Work&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;/rdf:RDF&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;/metadata&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;defs&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;defs845&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;sodipodi:namedview&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="na"&gt;pagecolor=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;#ffffff&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="na"&gt;bordercolor=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;#666666&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="na"&gt;borderopacity=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;1&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="na"&gt;objecttolerance=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;10&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="na"&gt;gridtolerance=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;10&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="na"&gt;guidetolerance=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;10&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="na"&gt;inkscape:pageopacity=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;0&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="na"&gt;inkscape:pageshadow=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;2&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="na"&gt;inkscape:window-width=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;1920&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="na"&gt;inkscape:window-height=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;1121&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;namedview843&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="na"&gt;showgrid=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;false&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="na"&gt;inkscape:zoom=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;0.5&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="na"&gt;inkscape:cx=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;288&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="na"&gt;inkscape:cy=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;288.00062&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="na"&gt;inkscape:window-x=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;-9&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="na"&gt;inkscape:window-y=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;-9&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="na"&gt;inkscape:window-maximized=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;1&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="na"&gt;inkscape:current-layer=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;svg841&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;path&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="na"&gt;d=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;m 201.18908,347.40454 c 0,20.21087 -16.38399,36.59489 -36.59483,36.59489 -20.21084,0 -36.59425,-16.38402 -36.59425,-36.59489 0,-20.21086 16.38399,-36.59489 36.59483,-36.59489 20.21084,0 36.59425,16.38459 36.59425,36.59489 z m 100.37705,27.00002 C 296.79243,286.06164 226.03191,215.21187 137.59485,210.433 132.37485,210.15071 128,214.34501 128,219.57244 v 27.46802 c 0,4.80858 3.70857,8.84115 8.50685,9.15315 63.90394,4.16229 115.12733,55.25833 119.29818,119.29839 0.31257,4.79829 4.34514,8.50686 9.15314,8.50686 h 27.46797 c 5.228,5.7e-4 9.42228,-4.3743 9.13999,-9.5943 z m 82.42793,0.16458 C 379.1975,240.9576 271.69416,132.82493 137.43028,128.00494 132.27028,127.8198 128,131.98837 128,137.15123 v 27.46745 c 0,4.92857 3.90571,8.94001 8.83028,9.14229 109.24505,4.47944 196.92954,92.18065 201.4084,201.40874 0.20171,4.92457 4.21314,8.83029 9.14228,8.83029 h 27.4674 c 5.16228,-5.7e-4 9.33085,-4.27086 9.1457,-9.43086 z&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;path839&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="na"&gt;inkscape:connector-curvature=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;0&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;fill:#ffffff;fill-opacity:1;stroke-width:0.57142806&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/svg&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;(If there's still no scroll bar for the code sample when you're reading this:
Sorry, I'm working on it! If there is one: You're welcome!)&lt;/p&gt;
&lt;p&gt;When we boil the file down to the important parts, we end up with:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;table class="codehilitetable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;svg&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="na"&gt;xmlns=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;http://www.w3.org/2000/svg&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="na"&gt;viewBox=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;0 0 512 512&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;path&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="na"&gt;fill=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;#fff&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="na"&gt;d=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;m 201.18908,347.40454 c 0,20.21087 -16.38399,36.59489 -36.59483,36.59489 -20.21084,0 -36.59425,-16.38402 -36.59425,-36.59489 0,-20.21086 16.38399,-36.59489 36.59483,-36.59489 20.21084,0 36.59425,16.38459 36.59425,36.59489 z m 100.37705,27.00002 C 296.79243,286.06164 226.03191,215.21187 137.59485,210.433 132.37485,210.15071 128,214.34501 128,219.57244 v 27.46802 c 0,4.80858 3.70857,8.84115 8.50685,9.15315 63.90394,4.16229 115.12733,55.25833 119.29818,119.29839 0.31257,4.79829 4.34514,8.50686 9.15314,8.50686 h 27.46797 c 5.228,5.7e-4 9.42228,-4.3743 9.13999,-9.5943 z m 82.42793,0.16458 C 379.1975,240.9576 271.69416,132.82493 137.43028,128.00494 132.27028,127.8198 128,131.98837 128,137.15123 v 27.46745 c 0,4.92857 3.90571,8.94001 8.83028,9.14229 109.24505,4.47944 196.92954,92.18065 201.4084,201.40874 0.20171,4.92457 4.21314,8.83029 9.14228,8.83029 h 27.4674 c 5.16228,-5.7e-4 9.33085,-4.27086 9.1457,-9.43086 z&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/svg&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;As you can see, this retains newlines and indentation for readability and is
still a great improvement size-wise. You could use this as-is in your CSS as
long as you escape all special chars (i.e. &lt;code&gt;&amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt;), but I prefer
&lt;code&gt;base64&lt;/code&gt;-encoding it before usage. This can be easily done with the &lt;code&gt;base64&lt;/code&gt;
command that is available on most GNU/Linux distributions. The encoded data
is then added to the CSS:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;table class="codehilitetable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt; 1&lt;/span&gt;
&lt;span class="normal"&gt; 2&lt;/span&gt;
&lt;span class="normal"&gt; 3&lt;/span&gt;
&lt;span class="normal"&gt; 4&lt;/span&gt;
&lt;span class="normal"&gt; 5&lt;/span&gt;
&lt;span class="normal"&gt; 6&lt;/span&gt;
&lt;span class="normal"&gt; 7&lt;/span&gt;
&lt;span class="normal"&gt; 8&lt;/span&gt;
&lt;span class="normal"&gt; 9&lt;/span&gt;
&lt;span class="normal"&gt;10&lt;/span&gt;
&lt;span class="normal"&gt;11&lt;/span&gt;
&lt;span class="normal"&gt;12&lt;/span&gt;
&lt;span class="normal"&gt;13&lt;/span&gt;
&lt;span class="normal"&gt;14&lt;/span&gt;
&lt;span class="normal"&gt;15&lt;/span&gt;
&lt;span class="normal"&gt;16&lt;/span&gt;
&lt;span class="normal"&gt;17&lt;/span&gt;
&lt;span class="normal"&gt;18&lt;/span&gt;
&lt;span class="normal"&gt;19&lt;/span&gt;
&lt;span class="normal"&gt;20&lt;/span&gt;
&lt;span class="normal"&gt;21&lt;/span&gt;
&lt;span class="normal"&gt;22&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nt"&gt;ul&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;icons&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;icon-blog&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nd"&gt;before&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nf"&gt;url&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;data:image/svg+xml;base64,\&lt;/span&gt;
&lt;span class="s1"&gt;             PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIg\&lt;/span&gt;
&lt;span class="s1"&gt;             NTEyIj4KICA8cGF0aCBmaWxsPSIjZmZmIiBkPSJtIDIwMS4xODkwOCwzNDcuNDA0NTQgYyAwLDIw\&lt;/span&gt;
&lt;span class="s1"&gt;             LjIxMDg3IC0xNi4zODM5OSwzNi41OTQ4OSAtMzYuNTk0ODMsMzYuNTk0ODkgLTIwLjIxMDg0LDAg\&lt;/span&gt;
&lt;span class="s1"&gt;             LTM2LjU5NDI1LC0xNi4zODQwMiAtMzYuNTk0MjUsLTM2LjU5NDg5IDAsLTIwLjIxMDg2IDE2LjM4\&lt;/span&gt;
&lt;span class="s1"&gt;             Mzk5LC0zNi41OTQ4OSAzNi41OTQ4MywtMzYuNTk0ODkgMjAuMjEwODQsMCAzNi41OTQyNSwxNi4z\&lt;/span&gt;
&lt;span class="s1"&gt;             ODQ1OSAzNi41OTQyNSwzNi41OTQ4OSB6IG0gMTAwLjM3NzA1LDI3LjAwMDAyIEMgMjk2Ljc5MjQz\&lt;/span&gt;
&lt;span class="s1"&gt;             LDI4Ni4wNjE2NCAyMjYuMDMxOTEsMjE1LjIxMTg3IDEzNy41OTQ4NSwyMTAuNDMzIDEzMi4zNzQ4\&lt;/span&gt;
&lt;span class="s1"&gt;             NSwyMTAuMTUwNzEgMTI4LDIxNC4zNDUwMSAxMjgsMjE5LjU3MjQ0IHYgMjcuNDY4MDIgYyAwLDQu\&lt;/span&gt;
&lt;span class="s1"&gt;             ODA4NTggMy43MDg1Nyw4Ljg0MTE1IDguNTA2ODUsOS4xNTMxNSA2My45MDM5NCw0LjE2MjI5IDEx\&lt;/span&gt;
&lt;span class="s1"&gt;             NS4xMjczMyw1NS4yNTgzMyAxMTkuMjk4MTgsMTE5LjI5ODM5IDAuMzEyNTcsNC43OTgyOSA0LjM0\&lt;/span&gt;
&lt;span class="s1"&gt;             NTE0LDguNTA2ODYgOS4xNTMxNCw4LjUwNjg2IGggMjcuNDY3OTcgYyA1LjIyOCw1LjdlLTQgOS40\&lt;/span&gt;
&lt;span class="s1"&gt;             MjIyOCwtNC4zNzQzIDkuMTM5OTksLTkuNTk0MyB6IG0gODIuNDI3OTMsMC4xNjQ1OCBDIDM3OS4x\&lt;/span&gt;
&lt;span class="s1"&gt;             OTc1LDI0MC45NTc2IDI3MS42OTQxNiwxMzIuODI0OTMgMTM3LjQzMDI4LDEyOC4wMDQ5NCAxMzIu\&lt;/span&gt;
&lt;span class="s1"&gt;             MjcwMjgsMTI3LjgxOTggMTI4LDEzMS45ODgzNyAxMjgsMTM3LjE1MTIzIHYgMjcuNDY3NDUgYyAw\&lt;/span&gt;
&lt;span class="s1"&gt;             LDQuOTI4NTcgMy45MDU3MSw4Ljk0MDAxIDguODMwMjgsOS4xNDIyOSAxMDkuMjQ1MDUsNC40Nzk0\&lt;/span&gt;
&lt;span class="s1"&gt;             NCAxOTYuOTI5NTQsOTIuMTgwNjUgMjAxLjQwODQsMjAxLjQwODc0IDAuMjAxNzEsNC45MjQ1NyA0\&lt;/span&gt;
&lt;span class="s1"&gt;             LjIxMzE0LDguODMwMjkgOS4xNDIyOCw4LjgzMDI5IGggMjcuNDY3NCBjIDUuMTYyMjgsLTUuN2Ut\&lt;/span&gt;
&lt;span class="s1"&gt;             NCA5LjMzMDg1LC00LjI3MDg2IDkuMTQ1NywtOS40MzA4NiB6Ii8+Cjwvc3ZnPgo=&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;h3 id="outcome"&gt;Outcome&lt;a class="headerlink" href="#outcome" title="Permanent link"&gt;&amp;para;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The outcome is just as expected: The overall page weight could be reduced
drastically from 323.37&amp;nbsp;KB to 179.56&amp;nbsp;KB –&amp;nbsp;a reduction of more
than 44&amp;nbsp;%. The size of the transmitted HTML file (that contains the now
added CSS) increased by about 2&amp;nbsp;KB (note that the lines of CSS including
the font files could be removed, though) whereas the Font Awesome files were
about 146&amp;nbsp;KB, which is more or less the expected size reduction &lt;em&gt;for the
icons only&lt;/em&gt; of about 97&amp;nbsp;%, even though I've used the Font Awesome SVGs.&lt;/p&gt;
&lt;figure&gt;
    &lt;img alt="A pie chart showing the percentual shares of different parts of my 
CV website. HTML, CSS and the profile picture have a share of 98.15 KB 
(54.7 %) and the Raleway font 81.41 KB (45.3 %)."
         src="https://blog.philipp-trommler.me/en/images/2019/tb-svg-icons-pageweight-after.png" /&gt;
    &lt;figcaption&gt;The pageweight after switching to SVG icons in terms of
transmitted bytes. The web fonts are now taking up less than the half of the
size. Note that the weight of the profile picture still depends on the visitor's
display resolution.&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;The Raleway font that is still left takes up about 45&amp;nbsp;% of the page size
now, but I can accept the weight that it adds way easier than the size of the
Font Awesome font for two reasons (besides that it's only half the size):&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Raleway adds more to the overall look of the website than the four icons at
   the top. It's a really nice font and an eye-catcher. The size of the Font
   Awesome font didn't stand in a &lt;em&gt;healthy relation&lt;/em&gt; to what it added
   design-wise.&lt;/li&gt;
&lt;li&gt;The website works (technically) well without it. For people like me who have
   web font loading disabled by default (for obvious reasons, take a look at
   this article! 🤐), the website doesn't break because of the Raleway font.
   Everything is still readable and looks reasonably decent.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In other words: The icons are smaller now. And this is true both for the file
size as well as their appearance, because I didn't match their original size
exactly, as you can see on the following picture:&lt;/p&gt;
&lt;figure&gt;
    &lt;img alt="Two screenshots of my CV website showing the logos from the top of 
the page once using the font and once using the SVG icons. The icons using the 
SVGs are noticeable smaller."
         src="https://blog.philipp-trommler.me/en/images/2019/tb-svg-icons-old-new-comparison.png" /&gt;
    &lt;figcaption&gt;Icon size comparison: On the left is the old version using Font
Awesome's web font and on the right is the new version using SVGs. The
difference is small but noticeable in direct opposition.&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;One last interesting thing I stumbled upon while working on this: When editing
the Github icon I decided to remove the small dots on the tail of the Octocat.
They aren't noticeable in the size the icon is displayed anyways. Before
removing them the &lt;code&gt;base64&lt;/code&gt;-encoded SVG had 2906&amp;nbsp;bytes, afterwards it had
1451&amp;nbsp;bytes. I cannot imagine that this is solely because of the removed
dots but probably because Inkscape cleaned up the path element once it was
edited more than just resizing. Maybe making subtle changes on the other icons
before saving could reduce their size even further 🤔.&lt;/p&gt;</content><category term="Tiny Bits"></category><category term="fonts"></category><category term="icons"></category><category term="svg"></category><category term="web"></category></entry></feed>