chrisblakley / Nebula

Nebula is a WordPress theme framework that focuses on enhancing development. The core features of Nebula make it a powerful tool for designing, developing, and analyzing WordPress websites consistently, yet its deliberately uncomplicated code syntax also serves as a learning resource for programmers themselves.
https://nebula.gearside.com
GNU General Public License v2.0
141 stars 36 forks source link

Determine if Google Material Icons are a worthwhile replacement for Font Awesome #2298

Open chrisblakley opened 4 hours ago

chrisblakley commented 4 hours ago

The problem with Font Awesome is that as the library grows in features and versatility, so does the file size footprint. Their solution, which is a good one, is to allow projects to create their own subsets of only the necessary icons. However, because Nebula cannot determine which icons developers will use, it bundles the full Font Awesome Free library. Which includes:

Screenshot 2024-09-29 at 11 18 05 PM

That is 315kb total and makes these the largest assets in Nebula when combined and two of the woff files are the top 2 largest individual files themselves. This also does not include other variations such as "sharp", and does not include all of the "pro" icons– these are just the free versions.

Screenshot 2024-09-29 at 11 17 03 PM

Now, these assets are loaded (at least by default in Nebula) lazily after the Window Load event, but it is still worth determining if there is a better solution.

Google Material Icons:

Some interesting features/benefits

Some caveats with using Google Material icons


Here is one way to bring in an icon using Google Material Icons:

<span class="material-symbols-outlined">&#xE8B6;</span>
<span class="material-symbols-outlined">&#xE88A;</span>
<span class="material-symbols-outlined">&#xE8B8;</span>
<span class="material-symbols-outlined">&#xE87D;</span>

Here is a more intuitive way:

<span class="material-symbols-outlined">search</span>
<span class="material-symbols-outlined">home</span>
<span class="material-symbols-outlined">settings</span>
<span class="material-symbols-outlined">favorite</span>
<span class="material-symbols-outlined">favorite_border</span>

This would be a major change in Nebula, so this will not be a quick decision. The current plan is to stay with Font Awesome, but this will serve as a place for notes both for/against regardless of how serious the consideration to switch is.

chrisblakley commented 3 hours ago

Here is an initial quick test on the same page:

Screenshot 2024-09-29 at 11 44 03 PM

One thing to remember that technically, Google Material Icons would need to be smaller (and load faster) when combined with whatever solution is used for brand icons (such as social media icons), so if those need to use static/local images, then they should be accounted for in speed testing since Font Awesome Brands does include them inherently.

This test shows that FA Solid is at 153kb and Google Material (equivalent to Solid) at 125kb. This is close enough where this may be dead on arrival, and the focus should again be on how to better optimize Font Awesome itself...