You might be wondering how rendering icons with JavaScript affects performance. We worried about this quite a bit while we were developing it and even took some special measures to make sure it was as fast as we could make it.
Our testing shows that for the typical number of icons most people use on a site the loading and rendering time is faster than web fonts. Your mileage may vary, of course, and we'd love to hear about your experience if this turns out not to be the case for you.
We'll define these icons as symbols: pencil, trash, and star.
<!-- Define the symbols, these are invisible on the page --><idata-fa-symbol="delete"class="fas fa-trash fa-fw"></i><idata-fa-symbol="edit"class="fas fa-pencil fa-fw"></i><idata-fa-symbol="favorite"class="fas fa-star fa-fw"></i><!-- Use the defined symbols --><svg><usexlink:href="#edit"></use></svg><svg><usexlink:href="#delete"></use></svg><svg><usexlink:href="#favorite"></use></svg>
Using data-fa-symbol informs Font Awesome SVG with JavaScript to create the symbol. The value of this attribute becomes the name.
<!-- Name symbols with the value of data-fa-symbol --><idata-fa-symbol="picture-taker"class="fas fa-camera"></i><!-- Use the defined name --><svg><usexlink:href="#picture-taker"></use></svg>
Watch your CSS, Goose
Advertisement
Remove ads with a Pro plan!
A subscription to a Pro-level plan will remove all third-party advertisements on fontawesome.com.
And of course Pro-level plans come with…
All 7,864 icons in Font Awesome
5 Classic styles of every icon
4 Sharp styles of every icon
A Perpetual License to use Pro
Services and tools to make easy work of using icons
One of the downsides to SVG sprites is that extra styling is necessary to make them behave. When using symbols you will need to handle this yourself.
<style>.icon{width: 1em;height: 1em;vertical-align: -.125em;}</style><!-- Name symbols with the value of data-fa-symbol --><idata-fa-symbol="picture-taker"class="fas fa-camera"></i><!-- Use the defined name --><svgclass="icon"><usexlink:href="#picture-taker"></use></svg> Who doesn't like wafels?