unDraw for Websites
How to Optimize unDraw Illustrations for Faster Pages
Optimize unDraw illustrations for the web: honest SVG cleanup, right-sized PNG exports, compression, lazy loading and layout stability, without inventing savings figures.

Illustrations feel light compared with photographs, and individually they usually are. The weight creeps in at the page level: a landing page with a hero, six feature graphics, and a testimonial illustration is asking every visitor to download seven files before the page feels finished. To optimize unDraw illustrations properly you do not need exotic tooling. You need to remove what the file does not need, serve the size the layout actually uses, and load each image at the right moment. This guide covers those three jobs for SVG and PNG, and it is honest about a limit: the savings depend on your files, so measure your own pages rather than trusting anyone's percentages, including ours.
Start by measuring, not guessing
Optimization without measurement turns into superstition. Before changing anything, open your page in the browser developer tools, look at the network panel, and note which illustration files load, in what order, and at what size on disk. Sort by size. On most pages, one or two files account for most of the image weight, and those are where your effort pays back. Repeat the check after each change, and keep the numbers for your own site. A technique that halves a tiny icon changes nothing a visitor can feel; the same technique on a hero illustration might.
Optimize the SVG file itself
An SVG downloaded from unDraw is already a reasonably clean drawing, but files that have passed through editors often collect extra material. Open one in a text editor and you may find some of the following:
- Comments and editor metadata that describe the software, not the picture.
- Empty groups and unused definitions left behind by editing.
- Long decimal coordinates, where a path point is stored with far more precision than any screen can show.
- Embedded raster images, if a PNG was placed inside the SVG during editing, which quietly turns your vector into a heavy hybrid.
An SVG optimizer such as SVGO removes metadata, tidies groups, and rounds coordinates automatically. Run it on a copy, then compare the result side by side with the original at a large size before you ship it. Most cleanups are visually identical, but aggressive settings can merge paths in ways that change a drawing, and the only reliable check is your eyes on your artwork. Keep the unoptimized download as your master file, and treat the optimized version as a build artifact you can regenerate. Our guide to organizing your unDraw illustration files shows a folder habit that keeps masters and exports straight.
One more SVG decision matters more than any setting: use the SVG at all. Where a page can take a vector, it usually should, because one small text file replaces a whole set of pixel variants. The exceptions and the reasoning are laid out in unDraw SVG vs PNG.
Optimize the PNG export
PNG optimization is mostly about dimensions. A pixel file carries weight in direct proportion to how many pixels it holds, so the most effective step is also the simplest: export or resize the PNG to the largest size it will actually be displayed at, accounting for high density screens, and no larger. A illustration shown in a 700 pixel column does not need a file several times that width. Resizing downward is safe; resizing upward adds weight without adding detail.
After dimensions, compression helps at the margins. PNG is lossless, so optimizer tools can often rewrite the file more efficiently without changing a single visible pixel. Browser based tools such as Squoosh, published by the Google Chrome team, let you compare the original and the processed file side by side and try a palette based reduction, which suits flat color illustrations particularly well because they use few colors to begin with. Judge the comparison at full size, especially at edges between colors, and keep the master untouched.
Also consider whether the placement needs PNG at all. If the same illustration appears on a hand built page where SVG is welcome, switching format usually beats squeezing the PNG. In WordPress the calculation differs, and our unDraw PNG WordPress guide explains how the sizes WordPress generates already do much of this work for you.
Load each image at the right moment
Even a perfectly sized file is wasted if the browser downloads it long before anyone scrolls to it, competing with the content the visitor actually came for. The loading attribute solves this in one word:
<img src="images/feature.svg" alt="..."
width="640" height="480" loading="lazy">
With loading="lazy", the browser defers the request until the image is near the viewport. Apply it to illustrations below the first screenful: feature rows, in article graphics, footer artwork. Do the opposite at the top of the page. The hero illustration is often the largest visible element, and lazy loading it delays the very thing the visitor is waiting to see. Leave the hero eager, and if it is clearly the main element, fetchpriority="high" hints the browser to fetch it earlier.
Always pair lazy loading with width and height attributes. Without them the browser cannot know how much space to reserve, and deferred images arriving late will push content around. With dimensions in place, the box is held and the artwork simply fills it when it arrives.
Stability and delivery details
- Reserve the ratio everywhere. Width and height attributes, or the CSS aspect-ratio property, prevent layout shift for eager and lazy images alike. Our responsive illustrations guide covers the patterns.
- Reference shared artwork from one URL. If the same illustration appears in your header, your docs, and your blog, point all three at the same file path so the browser caches it once and reuses it.
- Let the server cache static files. Illustrations change rarely. Long cache lifetimes on your image folder, set in your host or server configuration, mean returning visitors skip the downloads entirely. Change the file name when you replace an illustration, so the new version is not masked by an old cached copy.
- Skip decorative weight on error pages and emails. Not every surface needs the full treatment; a small or omitted illustration on a utility page is a legitimate optimization.
Fewer files: audit what the page actually needs
The cheapest image is the one that is never requested. Before tuning any file, look at the page as a whole and ask whether every illustration is earning its download. Common findings on real pages: the same decorative scene used twice in one viewport, a large illustration illustrating a two line section, and artwork below a footer that most visitors never reach. Removing or shrinking one unnecessary hero sized file routinely saves more than every compression setting on the page combined. This is a design judgment, not a technical one, and it is why the measurement step comes first: the network panel shows you the candidates, and your eye decides which ones the page can lose.
Duplicates deserve a special mention. If your build process or CMS has uploaded the same illustration under three names, the browser treats them as three files and caches none of the savings. Consolidate on one canonical copy and update the references. The filing system in our guide to organizing unDraw illustration files prevents the duplicates at the source by giving each download one name and one home.
Inline or external: the SVG delivery choice
Small SVGs present a genuine trade off. Inlining a tiny illustration into the HTML removes a request entirely, which helps on a page with one or two small graphics. The cost is that the code travels with every page and cannot be cached separately, so inlining a large scene, or the same scene in a site wide header, quietly taxes every visit. A practical rule: inline only small, simple artwork that appears once, and keep everything else as external files the browser can cache. If you are weighing the two methods for the first time, our guide to adding an unDraw SVG to HTML compares them in detail, including the styling control that sometimes justifies inlining regardless of weight.
What not to do
- Do not serve one giant PNG to every device. A desktop width file on a phone is the single most common illustration performance problem, and srcset exists precisely to fix it.
- Do not lazy load the hero. Deferring the largest visible element delays the moment the page feels loaded. Lazy loading is for images the visitor has not reached yet.
- Do not upscale a small PNG and call it optimized. A bigger file with no extra detail is worse than the original on every measure.
- Do not strip the viewBox when cleaning an SVG. Overzealous cleanup that removes it breaks scaling and can render the artwork at a wrong or zero size. Whatever tool you use, open the result before shipping it.
- Do not convert illustrations to a photo format out of habit. Formats designed for photographs handle flat color and sharp edges poorly and often produce larger files with visible artifacts around the lines. Keep line art in PNG or SVG unless you have compared the actual outputs.
- Do not install an optimization plugin and never look at the results. Automated tools make site wide changes. Spot check your most visited pages afterwards, in the browser, at phone and desktop widths.
Reading your results honestly
After a round of changes, describe the outcome the way you would want it described to you: with the actual before and after file sizes from your own network panel, for your own pages. Avoid converting that into a universal claim. Another site, with different artwork and a different audience, will see different numbers, and a guide that promises a fixed percentage is inventing precision it cannot have. What transfers between sites is the method: measure, fix dimensions, clean the vector files, load lazily below the fold, reserve the space, and measure again. Sites that follow the method end up fast for reasons they can point to, file by file.
Frequently asked questions
Is SVG always smaller than PNG?
Not always. Simple flat scenes are usually much smaller as SVG, but a highly detailed illustration with thousands of paths can outweigh a well sized PNG of the same scene. Compare the actual files for the artwork you are using; the answer takes a minute to check and settles the question for that image.
How small should an illustration be?
There is no universal target number, and any guide that names one without seeing your page is guessing. The useful test is comparative: is this file bigger than it needs to be for its display size, and is it bigger than the other illustrations on the page without a reason?
Does optimization change how the illustration looks?
Done properly, no. Resizing to display size, lossless cleanup, and lazy loading are all invisible when they are right. The moment a change is visible, such as banding in a gradient after palette reduction, it has gone too far for that image; back off and keep the better looking version.
A realistic order of work
| Step | Effort | Typical effect |
|---|---|---|
| Right size oversized PNGs | Low | Usually the largest saving on photo style pages |
| Run SVGO on edited SVGs | Low | Removes editor cruft and excess precision |
| Add lazy loading below the fold | Low | Faster first paint, fewer wasted requests |
| Add width and height everywhere | Low | Stops layout shift, no size change |
| Switch suitable PNG placements to SVG | Medium | One small file replaces several variants |
| Build a srcset for hero PNGs | Medium | Phones stop downloading desktop sized files |
Work down the list in order and remeasure after each step. Stop when the network panel shows a page you are content with. Optimization has diminishing returns, and an afternoon spent chasing the last few kilobytes of a small illustration is an afternoon not spent on the content the illustration supports.
Quick checklist
- Network panel reviewed; the heaviest illustrations identified by name.
- Master files kept separate from optimized exports.
- SVG files cleaned with an optimizer and compared visually afterwards.
- PNGs exported at display size, never enlarged.
- Lazy loading on below the fold images only; hero left eager.
- Width and height attributes present on every illustration.
- Shared artwork referenced from a single URL so caching works.
