How to Set an Image Budget for Programming Tutorials

A single 900 kB screenshot in a C# tutorial can weigh more than the HTML, CSS, fonts, and JavaScript put together. But the file size in your media library doesn’t tell you what a reader downloads. A phone might get a smaller copy, and a screenshot near the end of the tutorial might not load until the reader scrolls. Base your image budget on the bytes the browser actually fetches, not the files an editor uploads.

1. Define what your budget covers

A page weight budget limits how much data a page can transfer under specific test conditions. The image budget is the share reserved for images. For a programming tutorial, track the cost of opening the page separately from the cost of reading the whole thing. Moving a heavy screenshot farther down can get the page under its opening limit without saving a single byte for someone who follows every step.

  • Initial image budget: Count the bytes transferred by image requests during a fixed window after opening the page, without scrolling. Include the hero (the main image at the top), author avatar, and template graphics if the browser requests them as separate files.
  • Full-article image budget: Count the cumulative image bytes after scrolling through the article in a consistent way. This total includes the initial load; it’s not a second allowance.
  • Per-image guideline: Give editors a target for common assets, such as a hero, an IDE screenshot, or a diagram. These targets help with export decisions, but the measured totals determine whether the tutorial passes.

Decide how you’ll count images that don’t have their own requests. An inline SVG adds to the HTML transfer, while an image embedded in a stylesheet adds to the CSS transfer. Keep those bytes in the overall page budget even if the browser’s image filter doesn’t show them. Stick to one unit throughout: the examples here use decimal kB, where 1 kB is 1,000 bytes.

2. Measure a few real tutorials before choosing a number

Pick tutorials that share a template but use images differently. A short post about JavaScript promises might need one diagram, while a Visual Studio walkthrough might use screenshots at several steps. Include a page with a hero and a tutorial with as many figures as you typically publish. The lightest post alone won’t tell you what editors can reasonably work with.

A developer checks requests in the browser’s Network panel

  1. Open the preview and clear the Network log. In your browser’s developer tools, turn on the option to disable the cache while the tools are open. If a service worker can serve cached assets, bypass it for this cold-load test and record that choice so you can repeat it.
  2. Record the test settings. Note the browser, viewport, device pixel ratio, and network settings. A viewport 390 CSS pixels wide with a device pixel ratio of 2 is a reasonable starting point, but check what makes sense for your audience. Test a desktop viewport separately: it may load a larger hero.
  3. Reload without scrolling. Record the total transferred bytes and the image subtotal after a fixed interval. For a manual baseline, you could take the reading ten seconds after opening the page. If requests are still pending, note them rather than treating the incomplete total as a pass.
  4. Scroll through the article without clearing the log. Move about one screenful at a time so lazy-loaded figures have a chance to load. Stop at a defined point, such as the end of the article body, and wait for the image requests to finish before recording the cumulative total. Jumping straight to the bottom can skip figures in the middle.

Use the Network panel’s transferred size, not the resource size or decoded size. Decoded pixels matter for memory; transferred bytes are what the connection carries. Look at a few requests individually, too. A CSS background might be pulling in the full-width original on mobile, or a hidden alternate crop might still be downloading. For a responsive HTML image, check the request URL or the element’s currentSrc to see which file the browser picked.

3. Allocate bytes from the page total

Start with a test condition and a performance goal, then use your measurements to set a limit you can work with. At 1.6 megabits per second, for example, transferring 400 kB takes about two seconds at that rate alone. That gives you a sense of scale, not a prediction of when the page will appear. Latency, request scheduling, server response, and rendering also affect what the reader sees and when. Test the budget with network throttling before settling on it.

Say you start with a 500 kB initial page cap. On a representative cold load, non-image resources take up 240 kB. Set aside another 60 kB for variation and you have 200 kB for initial images. These are example numbers, not web standards. If the non-image total varies widely, run the test several times and budget for the heavier end of normal before assigning what’s left to images.

For the full-article limit, work through a typical lesson. With a 650 kB cap and 180 kB already used by opening images, you have 470 kB left. Five screenshots at 70 kB each and a 90 kB diagram bring the total to 620 kB, leaving 30 kB to spare. If one screenshot needs 105 kB to keep a dialog label readable, the total rises to 655 kB. It may be easier to save 5 kB elsewhere than to make that label harder to read.

Report the image and page caps separately. A tutorial can meet its 200 kB initial image allowance and still go over 500 kB because of a new code-highlighting bundle. And if a page comes in under budget, there’s no need to spend the difference. That spare capacity leaves room for future template changes without making editors re-export old figures.

4. Choose the smallest version that still teaches the step

Back up the original images and site configuration before changing image presets or replacing media in bulk. If the change will update attachment records or article markup in a CMS, back up the database as well. Check new exports on a preview page before replacing published files. Keep the original screenshot so you have a clean source if you need a different crop later.

Crop screenshots around the action

If a reader needs to find one menu item in Visual Studio, a crop that shows the menu and its panel is usually more useful than the full desktop. Leave enough context for the reader to locate the control, then check the export at the size it will appear in the article. If readers need to copy a command or compare error text, include it as HTML text too. Saving bytes isn’t worth making a step harder to follow.

Pick a format by inspecting the result

Try lossy WebP or AVIF for a photo used as a hero, provided your site can serve a compatible alternative where needed. For interface screenshots, compare lossless WebP with an optimized PNG. Heavy lossy compression can blur small lettering or leave artifacts around sharp edges. For a simple diagram, an optimized SVG from a trusted source can save bytes and stay sharp at different sizes. Compare the exports themselves: the format name won’t tell you which file is smallest while still looking good enough.

Give the browser widths that match the layout

List available image widths in srcset and use sizes to tell the browser how wide the image will appear. If the article column is capped at 760 CSS pixels, don’t tell the browser the image fills the entire desktop viewport. It may pick a larger file than it needs. On mobile, a slot 360 CSS pixels wide at a device pixel ratio of 2 needs roughly 720 source pixels for a sharp result. Offer a candidate near that width instead of making the browser choose between a tiny thumbnail and a 2,400-pixel original. Then check the Network panel to see what actually loaded.

5. Keep the opening fast without hiding later costs

Lazy-load images farther down the article when readers don’t need them right away. The browser may fetch some before they come into view. If any transfer during the no-scroll test, count those bytes toward the initial budget.

Don’t lazy-load the hero if it’s likely to be the Largest Contentful Paint (LCP) element. LCP measures when the largest visible image or text block appears. Keep the hero easy for the browser to find in the HTML, and don’t give an entire gallery high priority. Those requests can compete with the hero.

Set width and height attributes that reflect each image’s aspect ratio, then use CSS to scale it within the article column. This reserves space so a paragraph doesn’t jump when the image appears. Check transfer size, rendering speed, and layout stability separately: a small hero can still appear late if the browser discovers it late, and even a tiny screenshot can shift the text if the page hasn’t reserved space for it.

6. Put the budget where editors can use it

Add the initial cap, full-article cap, and per-image targets to the template you use to write a content brief for a programming tutorial. Ask authors to mark which figures readers need to complete a step and which are decorative. If the preview is over budget, the reviewer can simplify or remove a decorative image before touching the screenshot that shows how to recover from a build error.

Start with a simple publishing check: record the test viewport, both image totals, and the URL and transferred size of the largest image request. Once the check is repeatable, you can automate it with a browser test on your staging site. Keep the cache policy, observation window, and scrolling steps the same so a test change doesn’t look like a page change. If the checker filters requests by resource type, confirm that it counts standalone SVGs and CSS background images. Keep the overall transfer check as well, so it picks up image bytes embedded in HTML or CSS.

Set different limits for recurring formats only when readers use them differently. An illustrated IDE walkthrough may need more bytes across the full article than a short language reference, but it doesn’t necessarily need a heavier opening. For a one-off exception, record the article, exactly how far it went over, and why. That gives the next reviewer a decision they can understand without raising the cap for every page.

When a preview fails, sort the Network log by transferred size before opening an image editor. If several tutorials load the same oversized banner, fix the shared component and rerun the cold-load tests. If the problem is one 140 kB screenshot, try cropping out unused panels and exporting it again. Compare both versions at the article’s mobile display width. If the smaller file saves more than the overage and the menu label is still readable, replace that one screenshot rather than recompressing every figure on the page.