Assets are the bytes a page sends besides its HTML: images, fonts, scripts, stylesheets, and for a game, textures, atlases and audio. They dominate the transfer size of almost every gaming page. This guide covers each asset type with the technique that reduces its cost and the trade-off that technique carries, because every optimization here has one, and applying them blindly produces a page that is smaller and worse.

Images

Formats

Choosing an image format for a game page Decision flow. Vector artwork such as icons and logos becomes SVG. Photos and textures use AVIF with WebP and JPEG fallbacks in a picture element. Images needing transparency use AVIF or WebP with alpha, with PNG only as a last resort. Sets of many small game sprites are packed into a texture atlas with coordinates. Always serve correct dimensions, use srcset and sizes, set width and height attributes, and lazy-load only below the fold. What is the image?start hereSVGicons, logos, UI line artvectorPhoto or textureraster, many coloursAVIF → WebP → JPEG<picture> with fallbacksNeeds transparency?alpha channelAVIF / WebP (alpha)PNG only as last resortGame sprite set?dozens of small imagesTexture atlasone sheet + coordinatesAlways: correct dimensions, srcset/sizes, width + height attributes.Lazy-load below the fold only; never the LCP image.
Image format decision. Vector → SVG. Photo → AVIF/WebP/JPEG. Alpha → AVIF/WebP, PNG last. Sprite sets → atlas. Dimensions and lazy-loading rules apply in every branch.

MDN's image format guide is the reference. In short: SVG for anything drawn with lines and flat colours, because it scales to any resolution, compresses well as text, and can be styled with CSS. AVIF for photographic and textured images, with the best compression of the widely supported formats and support for transparency and HDR; its trade-off is slower encoding and, on some devices, slower decoding. WebP as the fallback for AVIF, with broad support and good compression. JPEG as the universal fallback for photos. PNG only when lossless pixels are truly required, because it is large; most transparency use cases are better served by AVIF or WebP with alpha. GIF has no place on a modern page; animated images belong in video or animated AVIF/WebP.

The <picture> element lets the browser choose the first format it supports:

<picture>
  <source type="image/avif" srcset="hero-800.avif 800w, hero-1600.avif 1600w" sizes="(max-width: 820px) 100vw, 820px">
  <source type="image/webp" srcset="hero-800.webp 800w, hero-1600.webp 1600w" sizes="(max-width: 820px) 100vw, 820px">
  <img src="hero-800.jpg" srcset="hero-800.jpg 800w, hero-1600.jpg 1600w" sizes="(max-width: 820px) 100vw, 820px"
       width="1600" height="900" alt="Describe the image" fetchpriority="high">
</picture>

Responsive images

srcset with width descriptors lists candidate files; sizes tells the browser how wide the image will be rendered at each breakpoint; the browser multiplies by the device pixel ratio and picks the smallest adequate candidate. The trade-off is operational: more files to generate and store, and a sizes attribute that must be kept in sync with the CSS or the browser will pick wrong. Always include intrinsic width and height attributes so the box is reserved before the image arrives.

Lazy loading

loading="lazy" on an <img> or <iframe> defers the fetch until the element is near the viewport. It removes bytes from the initial load and is the right default for everything below the fold. The trade-off is that a lazy image the user scrolls to quickly arrives late, and a lazy image that turns out to be the LCP element adds its full fetch to LCP. Never lazy-load above the fold, and for a game page do not lazy-load the poster inside the game container. decoding="async" is a smaller, complementary hint that lets the browser decode an image off the critical path.

Fonts

Web fonts cost a request per file, delay text rendering until they arrive or until a timeout, and can cause a layout shift when they swap in with different metrics from the fallback. web.dev's font best practices cover the mitigations: subset the font to the characters you use, serve WOFF2, preload the one or two files needed for the first paint, and set font-display: swap or optional with a size-adjusted fallback so the swap does not move text. The alternative is to use the system font stack and ship no font files at all, which is what this site does; the trade-off is giving up a brand typeface. For a game's in-canvas text, bitmap fonts rendered from an atlas avoid the issue entirely.

Preload and priority hints

<link rel="preload"> tells the browser to fetch a resource now that it would otherwise discover late: a font referenced from CSS, a hero image set as a background, the game's first atlas. fetchpriority="high" on an <img> or a preload raises it in the browser's queue. Both are powerful and both are easy to misuse. Every preload competes with the resources the browser would have prioritised itself, so preloading more than a handful of things makes everything slower. Preload only what the first paint needs and cannot discover from the HTML; mark only the LCP image as high priority.

Compression

Text assets (HTML, CSS, JavaScript, SVG, JSON) compress well and should always be served with Content-Encoding: Brotli where the client accepts it, gzip otherwise. Brotli, specified in RFC 7932, generally produces smaller output than gzip at its higher levels at the cost of slower compression, which is why it suits pre-compressed static files and CDNs. Already-compressed formats (AVIF, WebP, JPEG, WOFF2, MP4, most audio) gain nothing from a second pass and should be excluded. The CDN guide covers the server configuration and the Vary header that caches need.

Sprites and texture atlases

For a game, packing sprites into atlases is the single most effective asset change: fewer requests, better compression of similar imagery, and one GPU texture per scene instead of hundreds. The trade-offs are cache granularity (a one-sprite change invalidates the sheet), memory (an atlas is resident in full even if only part is used), and the maximum texture size supported by the weakest GPU you target. Keep atlases per scene, name them by content hash so they cache for a year, and compress the image data with a format the game runtime can decode quickly. For the page's own UI icons, an inline SVG sprite with <use> references gives the same benefit without a raster.

JavaScript chunk size

JavaScript is the most expensive byte on the page because it must be parsed and compiled, not only downloaded. Code splitting breaks a bundle into chunks that load on demand: the page framework's core now, a feature's code when the feature is used, the game runtime when the container is in view. web.dev's code-splitting guide covers the tooling. The trade-off is request overhead and a brief delay at the moment the chunk is needed; over HTTP/2 the overhead is small, and the delay is manageable with a prefetch once the page is idle. Budget the critical bundle, measure it in CI, and treat any third-party script as a chunk you did not write and cannot shrink.

CSS delivery

CSS blocks rendering, so the stylesheet needed for the first viewport should be small and arrive early. The common pattern is to inline the critical rules in the HTML and load the full stylesheet without blocking, or simply to keep the whole stylesheet small enough that the distinction stops mattering. Remove unused rules, avoid @import (it serialises requests), and split print and rarely used styles into stylesheets with a media attribute so they load at low priority. content-visibility: auto lets the browser skip rendering work for off-screen sections of long pages.

Budgets and the calculator

A performance budget is a limit on transfer size per asset class that the build enforces. The right numbers depend on the audience's connection; the asset weight calculator on this site estimates compressed transfer size and rough download time from the sizes you enter, with its assumptions stated, so you can see what a given budget means on a slow connection. It is an educational approximation, not a measurement of any site.

TechniqueSavesCosts
AVIF / WebP with fallbackslarge share of image bytesencode time, more files, decode cost on weak devices
srcset / sizesoversized images on phonesmore variants; sizes must match CSS
Lazy loadinginitial bytes below the foldlate images on fast scroll; fatal if applied to LCP image
System fontsall font bytes, swap shiftsno brand typeface
Preload / fetchprioritydiscovery delay for key assetsstarves other resources if overused
Brotlitext bytes versus gzipslower compression; pre-compress static files
Texture atlasesrequests, draw callscache granularity, texture memory
Code splittingcritical JavaScripton-demand delay; more requests
Critical CSS inliningrender-blocking round tripduplicated bytes, build complexity

Sources

Primary documentation consulted for this guide. Thresholds and API behaviour were checked against these pages on 2026-11-02.

  1. Image file type and format guide — MDN Web Docs
  2. Responsive images — MDN Web Docs
  3. Lazy loading — MDN Web Docs
  4. Browser-level image lazy loading — web.dev
  5. HTMLImageElement: loading property — MDN Web Docs
  6. HTMLImageElement: decoding property — MDN Web Docs
  7. Best practices for fonts — web.dev
  8. font-display — MDN Web Docs
  9. rel=preload — MDN Web Docs
  10. Preload critical assets to improve loading speed — web.dev
  11. Optimizing resource loading with the Fetch Priority API — web.dev
  12. <script>: the Script element (async, defer, module) — MDN Web Docs
  13. Reduce JavaScript payloads with code splitting — web.dev
  14. Compression in HTTP — MDN Web Docs
  15. RFC 7932: Brotli Compressed Data Format — IETF RFC Editor
  16. Optimize Largest Contentful Paint — web.dev
  17. content-visibility — MDN Web Docs