Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

laracoft's avatar

"Best" way to utilize icons

Hi,

I'm curious how you guys are utilizing icons in your apps.

UPDATE: Can someone explain why inline SVG is better than CDN CSS?

  1. It used to be just including a CDN CSS link and writing <i class="fa fa-shopping-bag" aria-hidden="true"></i>, e.g. fontawesome 4, I read somewhere that this is not efficient
  2. Fontawesome 5 seems to use something very complicated which I haven't figure out yet
  3. I came across another https://github.com/feathericons/feather#quick-start which uses javascript, this breaks, i.e. the icons don't show up, when the DOM is replaced after the page is loaded
  4. Are there other easier, efficient and robust ways, especially one that is able to include icons from other libraries?

Thank you.

0 likes
14 replies
laracoft's avatar

@tykus

Thanks, yes, I'm using Tailwind CSS and already added animate-spin to the SVG @svg('feathericon-chevrons-left', 'animate-spin w-4 h-4') but it just doesn't spin, I guess it has something to do with my setup of Tailwind CSS

laracoft's avatar

@tykus

It's spinning now, basically my app.css wasn't updated to include animate-spin, thanks once again!

tykus's avatar

Mostly using SVG icons these days, e.g. heroicons. They're markup, scale easily, and are easy to componentize.

laracoft's avatar

You guys are fast, can someone explain the pros vs cons of using inline SVG vs CDN CSS?

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@laracoft Inline means that it just shows the svg directly. If you use a cdn, then the browser needs to download all icons before it can use them

laracoft's avatar

@Sinnbeck

For a while there, I felt inline SVGs violated the DRY principle, but since they are not that big in size, not often repeated and can be abstracted into blade components, I guess it is similar to tailwind, just a matter of getting used to.

Thank you.

Snapey's avatar

the con of icon libraries via cdn is pulling in hundreds of icons when you only need two or three as well as tying you in to a specific set of icons

Please or to participate in this conversation.