Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FontAwesome 5 SVG icons: data-search-pseudo-elements causes 100X slowdown in rendering

When I enabled data-search-pseudo-elements it causes a 100x+ slowdown in the performance of rendering rows with icons within a grid. Whats strange is that the grid virtualizes the rows, so really only 100 rows may be visible. Without this setting render time is .5 seconds. With this setting it is >30 seconds and often crashes the browser altogether. The icons in question aren't from pseudo elements, but I enabled this feature in my index.html for a targeted use in another part of the app.

Is there any way to use a pseudo class icon without enabling that, or to scope it to only affect a certain area?

like image 819
Josh Avatar asked Jun 21 '18 20:06

Josh


People also ask

How do I use Font Awesome icon in pseudo element?

Enable Pseudo-elements Using CSS Pseudo-elements to render icons is disabled by default when using our SVG + JS Framework. You'll need to add the <script data-search-pseudo-elements ... > attribute to the <script> element that calls Font Awesome.

Does Font Awesome use SVG?

Just like any other style of Font Awesome icons, you can drag and drop a Duotone SVG file into your SVG-friendly application, and the duotone icon will appear.

Why do some FontAwesome icons not work?

If you installed the Free Font Awesome version but try adding Pro icons to your web pages, they won't show. The solution to this is either you use the alternative free icons or upgrade to a Pro subscription/license.

Is FontAwesome heavy?

Since fontawesome is a huge file, we have to trim it down to our needs. If we are using only 10 icons then why should we load 100 other icons? The size of font awesome web font is 90KB. Added to that, minified font awesome css is 30KB.


1 Answers

Using data-search-pseudo-elements with the SVG/JavaScript implementation has known performance concerns, documented here:

Although you can use pseudo-elements with SVG and JS we do not recommend using this method. It does not provide as many usage options, is difficult to configure, and is the slowest method of using Font Awesome. (Painfully slow in some cases.)

At this time, there's no configuration option to limit the scope of the pseudo-elements search and replace feature.

If you're stuck using pseudo-elements but the performance with the SVG/JavaScript method is inadequate, then your best option may be to switch to the Web Fonts & CSS method.

That said, I'm curious to have a closer look at your scenario to see if there are any optimizations that could be made. Could you post a CodePen?

like image 199
mwilkerson Avatar answered Sep 23 '22 12:09

mwilkerson