Sub topic 7
Exporting Assets at the Right Scales with Clear Names
This chapter assumes you know the common image formats (SVG, PNG, JPEG, WebP) and can mark layers for export in a design tool such as Figma, Sketch, or Adobe XD. The previous chapter covered which format fits which kind of image. Here you decide how many files to export, at what sizes, and what to call them.
Why scale and names matter
A developer cannot guess which file is the 2x version of which image. Wrong sizes cause two problems. Files that are too small look blurry on high-density screens. Files that are too large slow down the page. Unclear names cause a third problem: developers rename files, and then the design and the code no longer match.
Choose scales by asset type
Scale is the multiple of the design's pixel size at which you export. A 24 px icon exported at 2x is 48 px wide.
| Asset type | What to export | Scales |
|---|---|---|
| Icons, logos, simple illustrations | SVG | None. SVG is vector and scales without loss. |
| UI graphics with fixed size (badges, sprites) | PNG | 1x and 2x, sometimes 3x |
| Photos | WebP, plus JPEG as fallback | Two or more widths, such as 800 and 1600 px |
| Large hero or background images | WebP, plus JPEG as fallback | Widths that match your breakpoints |
For photos, export by width in pixels, not by a scale label. The browser picks a file based on the screen width and pixel density, so it needs a list of real widths.
Name files so they sort and explain themselves
Use one pattern for every asset. A good pattern is:
type-subject-variant-size.format
Follow these rules:
- Use lowercase letters, digits, and hyphens. Avoid spaces, capitals, and special characters, because they break URLs and behave differently across operating systems.
- Name the content, not the appearance or location.
icon-search.svgis better thanmagnifier-blue-top-right.svg. - Put the width in the name when you export several sizes, such as
hero-800.webpandhero-1600.webp. - Use the same words as the layer and component names in the design file, so a developer can search for either.
Here is the result for one set of exports.
assets/
icons/
icon-search.svg
icon-close.svg
images/
hero-800.webp
hero-1600.webp
hero-800.jpg
hero-1600.jpg
logo/
logo-primary.svgConnect the files to the code
The exported names should map directly to the markup the developer writes. The example below uses the hero files from the listing above. The width and height attributes reserve space, which prevents the page from jumping as the image loads.
<picture>
<source type="image/webp" srcset="hero-800.webp 800w, hero-1600.webp 1600w" sizes="(min-width: 960px) 50vw, 100vw">
<img src="hero-800.jpg" srcset="hero-800.jpg 800w, hero-1600.jpg 1600w" sizes="(min-width: 960px) 50vw, 100vw" width="800" height="450" alt="Team reviewing a design on a shared screen">
</picture>Each filename appears in the markup exactly as exported. Because of that, the handoff should also state the sizes intent, for example "half the viewport from 960 px, full width below". The developer then does not have to work it out from the layout.
Common errors
- Exporting a photo as PNG. The file is often several times larger than the same image in WebP or JPEG.
- Exporting SVG icons with fixed colors when the code needs to change the color. Ask the developer whether the fill should be
currentColor. - Leaving an icon's export area larger than its artwork, so spacing in the code is off. Crop the export frame to the intended icon box.
- Exporting only 1x images. Screens with a high pixel density then show them blurred.
- Renaming files after export without updating the handoff notes.
Exercise
You need to hand off a 600 px wide product photo that appears at full width on mobile and at half width on desktop. Name two files you would export, say which format each uses, and explain why you export more than one width.
Show answer
For example, product-600.webp and product-1200.webp, with product-600.jpg and product-1200.jpg as fallbacks. WebP is the primary format because it gives smaller files, and JPEG covers browsers that lack WebP support. Exporting two widths lets the browser pick the 1200 px file on high-density screens and the 600 px file on standard screens, so users avoid both blurry images and needless downloads.
Exercise
A teammate exports a set of icons named Blue Arrow (final) 2.png. List three problems with this name and propose a better one for a right-pointing arrow icon.
Show answer
The name has spaces and capitals, which cause trouble in URLs and across operating systems. It describes a color and a version ("Blue", "final 2") instead of the content. PNG is also the wrong format for a simple icon, since SVG scales without loss. A better name is icon-arrow-right.svg.