Web DevelopmentArchive edition6 min read

Designing a fast website from the first request

The first screen should arrive before secondary features compete for bandwidth.

Abstract layered interface panels and aligned lines — Designing a fast website from the first request
Original ARTware computational illustration.

A visitor on a busy mobile connection does not experience a website as a single completed object. The browser begins by locating the server, establishing a connection and requesting a document. Only after some of that work has happened does it discover the resources described by the document. Images, styles and scripts then arrive at different speeds. A page may look almost empty while its network activity is already quite substantial.

The first useful design exercise is therefore to identify what the visitor should be able to see and use early. On an editorial website, that is likely to be the title, navigation and opening paragraph. On a catalog, it might be the product name, thumbnail and price indication. The decision is different from merely aiming to make every asset as small as possible. It establishes a priority for the requests and rendering work that support the initial view.

Follow the journey from connection to content

A cold visit includes work that a repeat visit may not require. Name resolution, a new secure connection and the first response can all affect how long a page appears to do nothing. Examine a request timeline rather than relying exclusively on a headline performance number. If the document takes a substantial amount of time to arrive, an optimized image cannot make that document available sooner. The resource serving the document deserves an investigation before the later requests do.

Distinguish connection time from processing time. A geographically distant visitor might wait for network round trips even when the server handles the request quickly. An application that assembles content from multiple dependencies may spend most of its time waiting for a data response. Stable pages that were generated before the request have different characteristics from pages that must make several live decisions. The right improvement depends on what the measurements reveal. For some sites, shortening a sequential dependency chain removes more delay than changing the frontend layout would ever remove.

Keep the initial document useful

HTML is not merely the wrapper around a collection of resources. It describes the content and tells the browser which resources need to be loaded. A server that returns a nearly empty HTML document and waits for code to assemble an ordinary article forces the visitor through an unnecessary sequence. First the document arrives, then the code, then a content request, and finally the article becomes available. Returning the article itself in the document can remove several of those dependencies.

Stylesheets require similar attention. A vast shared stylesheet may contain rules for forms, dashboards, experiments and seldom visited pages. Yet a reader who opens a simple article may need only typography, navigation, a layout container and a few common components. A manageable common stylesheet is often appropriate, and maintaining too many fragments can harm consistency. The practical goal is not to split every rule into another request; it is to understand which styles are needed to render the first content and avoid sending unrelated complexity with them.

Related reading: Working with images in a performance budget.

Fonts present a subtle initial rendering problem. A design can use distinctive typography while still letting text appear with a suitable temporary typeface. Ideally the fallback occupies similar space, so changing to the intended typeface does not unexpectedly push a title onto another line or shift the rest of the page. Investigate actual behavior through a constrained connection, because a local machine with the font already cached is unlikely to reveal those conditions.

Put the first visual on its own footing

Consider a magazine homepage with a large illustration above the fold and smaller article cards beneath it. The large illustration directly contributes to the first view. The seventh card does not, although it should eventually become available as the reader explores the archive. Treating both requests identically assumes that the browser's available bandwidth is unlimited. Giving the prominent initial image an appropriate priority and delaying offscreen images has a clearer rationale.

Choose dimensions according to the intended display size instead of exporting every picture at the same maximum resolution. A source image several thousand pixels wide may be required for detailed artwork, but it does not necessarily belong in a mobile preview. Generate derivatives and compare their visible quality. Also specify the displayed image proportions so its space exists before the resource arrives. Reserving space cannot make image delivery faster, but it prevents a particularly irritating side effect: text or controls moving just as the user is about to act.

Abstract layered interface panels and aligned lines
ARTware visual study. A complementary computational composition.

Preloading is not a general instruction to apply to everything important. It brings forward the discovery of a known resource and can change the way available capacity is shared. If an initial image is already discovered promptly, forcibly preloading multiple alternative resources might achieve little or work against other requests. Use a real loading timeline to decide whether a resource is discovered too late. A small experiment with and without the instruction is more informative than assuming that a larger number of priorities means a faster page.

Budget the bytes on a representative page

A practical provisional budget for a small publication might be 80 kilobytes for the delivered document and critical styles, 150 kilobytes for its initial artwork and no scripting requirement for reading. These are illustrative targets, not universal limits. A detailed visual project may reasonably need more image data. A small reference page may need less. Write down why each allowance exists so a later addition can be evaluated against something concrete.

Suppose the first response currently appears after 900 milliseconds on a test connection. Meanwhile, an image near the bottom of the article occupies 70 kilobytes. Squeezing that image to 40 kilobytes will save bandwidth, but the 900-millisecond delay still exists. Now suppose the response is quick while a very large, immediately visible image postpones the main content. In that case the image export or its request timing is the more productive place to work. Both findings concern page speed, but their remedies are deliberately different.

Review transfer sizes as well as the files in the build directory. Text commonly travels in a compressed representation, and requests may be satisfied from a cache. A file that has already been downloaded on another route does not have the same cost as a cold download. Report the condition in which data was collected. Keeping one record for a first visit and a separate record for a repeat visit is more useful than blending the numbers together.

Avoid spending the entire budget before the visitor acts

Interactive features deserve individual scrutiny. A search box can be useful, but its operation should not prevent page headings or article links from appearing. A gallery viewer may need additional code once the visitor opens an image. A decorative animation can start after the essential content is ready. Separating these tasks reduces the amount of work that must happen at once, especially on a device that processes code slowly.

There is a maintenance trade-off here. An elaborate set of conditional loading rules may become its own problem and may behave inconsistently when templates change. Prefer a simple default that loads essential shared material promptly and adds route-specific behavior only on the pages that use it. Inspect the result when scripting is delayed. The most important reading and navigation paths should remain recognizable rather than presenting an unexplained blank space.

Repeat the measurement after the change

Test the same URL before and after altering its loading sequence. Keep the connection constraint, viewport and source content equivalent. Inspect the HTML response, the requests that delay rendering, the first appearance of meaningful content and the stability of its position. Repeat with a populated cache; a change that improves the first visit but repeatedly downloads replaceable resources may have an unnecessary long-term cost.

Finally, check another page with a substantially different structure. A performance improvement on the homepage may have moved a burden into the article template or introduced special assumptions that fail on a long title. Save a small record of the resource budget and the observed results alongside the release. The aim is to turn initial loading into an understandable property of the site, so the next editor or developer can add content without accidentally reversing the improvement.

Explore the implementation area: Web development.