Getting Started• 5 minutes read

Working with SVG Icons

Use SVG for logos, icons, badges, and simple illustrations that need to remain sharp at any size. Use WebP or another raster format for photographs and detailed imagery.

SVG files are code, so treat them carefully:

  • Download them from sources you trust and check the license.
  • Optimize unnecessary design-tool markup.
  • Sanitize every upload with a maintained tool.
  • Restrict who can upload SVG files.
  • Add accessible text when the graphic carries meaning.

Inline an SVG only when you need to style or animate it as part of the page. An external file is usually easier to cache and manage.

Every detail matters when someone lands on your store. A blurry logo, chunky icons, or graphics that look fine on desktop but soft on mobile can make a site feel less polished.

That is where SVGs can help.

SVGs are often the best choice for logos, icons, badges, and other simple graphics because they stay sharp at any size and are usually very lightweight.

This guide explains how to use them correctly.

What is an SVG?

Most images on the web are either raster or vector.

Raster images are your typical ones like JPEG, PNG, and WebP. They are made of pixels. They work well for photos, but will get blurry if you enlarge them too much.

SVG stands for Scalable Vector Graphics. Instead of pixels, SVGs use instructions that tell the browser how to draw shapes, lines, and colors. Because of that, they stay sharp no matter how large or small you make them.

Why SVGs are useful for Webstores

Here’s a typical example of an SVG:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"> <circle cx="50" cy="50" r="40" fill="#e74c3c" /> </svg>

And it creates a dot like this:

PNG Image

I optimized the image above for speed. The result is a file of about 1 KB.

However, the code above it is just ~100 bytes.

For comparison, 1 KB is 1,024 bytes.

In this deliberately simple example, the SVG is around 10 times smaller. You could display it at ten times the size without increasing the file size, which you cannot do with the PNG.

The saving will not always be tenfold, but the small file size and scalability make SVG a strong fit for simple graphics.

That makes SVGs especially useful for things like:

  • logos
  • cart icons
  • search icons
  • account icons
  • social icons
  • trust badges
  • payment icons

A single SVG logo will stay sharp everywhere.

These files add up, and keeping them light helps reduce page weight.

Since we covered how amazing SVGs can be, let’s get to the “scary part” now.

The Security Risk

SVGs are not just images. They are code-based files. This means they can sometimes contain unsafe code if they come from a bad source.

Because of this, WordPress blocks SVG uploads by default.

SVG uploads are enabled on your site. Users with sufficient upload permissions need to treat them as code, not harmless image files.

So you, who has admin privileges, should never upload them carelessly.

The safest approach is this:

  1. Only use SVGs from sources you actually trust
  2. Sanitize them before upload

A beginner-friendly option is to use a maintained SVG-upload tool that sanitizes files during upload. Safe SVG is one example. Check that the sanitizer is active before assuming an upload is safe.

But what is sanitization?

“Sanitize” means cleaning the file so it contains only safe drawing data and not any risky code:

<svg xmlns="http://www.w3.org/2000/svg">
  <circle cx="50" cy="50" r="40" fill="red" />
  
  <script>
    alert('This could steal session data');
  </script>
</svg>

Sanitization removes elements and attributes that should not be present in an uploaded image.

When Not to Use SVG

SVG is not the best format for everything.

Do not use SVG for:

  • product photos
  • banners with photographic backgrounds
  • complex artwork with lots of detail
  • images that look like photos

For those, use WebP instead. In some cases JPEG or AVIF can also make sense, but WebP is the easiest general recommendation for most store owners.

A good rule of thumb is this:

  • If it looks flat, simple, and graphic-like, SVG is often a good fit
  • If it looks like a photo, use WebP

SVG vs WebP: the easiest way to decide

If you are unsure which format to use, ask one question:

Does this image behave more like an icon or more like a photo?

Choose SVG for simple brand and interface graphics.
Choose WebP for photos and detailed image-heavy visuals.

If you really are not sure, export both and compare file sizes. Use the one that stays small while still looking good.

Should you optimize SVGs before uploading?

Yes.

Design tools often export SVGs with extra clutter that is not needed on a live website. That can make the file larger than necessary.

A simple tool like SVGOMG can help remove that extra bloat before upload.

For beginners, the workflow can be as simple as this:

  1. Export the SVG from your design tool
  2. Run it through SVGOMG
  3. Upload it to WordPress with a sanitizing plugin active
Same quality, almost half the size

That gives you a file that is smaller. For safety, you should still use a sanitizing plugin.

Inline vs. External SVGs

There are technical differences between inline SVGs and SVG files loaded as images, but most beginners do not need to get deep into that.

The practical version is:

  • Inline SVGs are often best for small header icons and other important interface elements
  • External SVG files are usually fine for badges, logos in content, and other non-critical graphics

On your site, you also have an option to inline your SVG images.

Use inline SVG deliberately for small interface graphics when you need to style or animate the SVG as part of the page. For ordinary content images and reusable logos, an external file is usually easier to cache and manage.

A Quick Note on Accessibility

You do not need to become an accessibility expert to get the basics right.

Just remember:

  • Give meaningful SVG images alt text when used as images
  • If an icon is only decorative, it should not distract screen readers
  • Treat SVGs the same way you would treat any other important image on your site

If you upload SVGs through the media library, do not skip the alt text field when it matters.

Good Places to Get SVG Icons

If you need icons for your store, try to use one consistent icon set so everything feels visually matched.

A few reliable options are:

Remember: If you download from a lesser-known source, always check the license before using icons on a commercial store. Some are free with attribution, while others allow free commercial use without it.

The Takeaway

SVGs are a great choice for WooCommerce stores – when used in the right places.

Get the basics right and SVGs can help your store look sharper and load lighter without much extra effort.