Profile a fast page: TTFB, images, and browser rendering
Ten local browser navigations compare smaller WebP delivery, Navigation/Resource Timing and LCP without promising an overall speedup.
A page can start responding quickly and still remain awkward to read for a long time. The first HTML byte does not show when the cover loaded, when the browser prepared it for display, or which largest element has been painted. Performance analysis should therefore begin with a sequence of events and a question about the specific delay we want to reduce.
The independent local experiment ran: five A and five B navigations alternated under one controlled protocol. The smaller WebP reduced bytes and median image Resource Timing duration, while the median final LCP candidate increased. The result calls for separating layers rather than promising an overall speedup.
Break the reader's wait into events
The teaching page contains a heading, a large image, and three text cards. The server returns the document, the parser discovers the image URL, and the browser receives its bytes and prepares a frame. These activities can overlap. Simply adding several durations does not necessarily produce the time when useful content appears.
For navigation, we define TTFB beforehand as responseStart - startTime. We separately record responseStart - requestStart, the narrower interval from the beginning of the request to its first response byte. Both numbers need clear names. Neither is, by itself, PHP or SQL execution time.
Navigation Timing Level 2 defines navigation fields and their time basis. Redirects, connection establishment, service workers, and other phases can affect intervals in a real environment. The local experiment has a shorter path, but its formula still needs declaring before execution so that we cannot later choose the more favorable definition.
Do not call transfer decoding
For the image, we retain the Resource Timing entry: start, response, completion, duration, transferSize, encodedBodySize, and decodedBodySize. The Resource Timing specification describes these resource fields. They let us examine data retrieval separately from document navigation.
Here, decodedBodySize means the body size after decoding HTTP content encoding. It is neither the size of expanded WebP pixels nor the duration of image decoding. The difference responseEnd - responseStart is not image decode time either. That conclusion requires separate events from an instrumented browser trace or a dedicated experiment.
The collector explicitly leaves decode duration unavailable. Even waiting for img.decode() would measure a promise-wait interval in a particular scenario, rather than automatically measuring the decoder's pure CPU time. When an instrument does not provide the required observation, retaining the gap is more useful than giving a familiar number the wrong name.
LCP adds evidence about painting
A PerformanceObserver should collect available largest-contentful-paint entries with buffering from the start of the page. We retain every candidate and the element identifier, rather than just one number. The large cover might become a candidate, but an actual entry must confirm that; the heading could also be an early candidate.
The Largest Contentful Paint specification explains the model of the largest painted content. This is separate browser evidence, rather than a synonym for network completion or complete page readiness. Our protocol reads the last available candidate after a fixed observation interval without user interaction.
If the browser does not support the entry or no candidate appears, the result is unavailable rather than zero. Every navigation in this run had entries, but the final candidate was not always the hero image. Comparing two numbers without checking the candidate would hide that distinction.
Make one controlled change between A and B
In the final protocol, both variants use a new geometric drawing produced programmatically for the teaching fixture. Variant A is a 2400 × 1200 WebP; variant B is a 1040 × 520 WebP. Their shape recipe, palette, proportions, format, and encoding settings are identical. The smaller image is a version matched to the fixed display size.
HTML and CSS are identical: the image occupies a 1040 × 520 rectangle at DPR 1 through the same resource URL. Only intrinsic WebP dimensions and resulting bytes change. A real browser confirmed identical DOM, computed styles and geometry. Raster rendering quality was not checked; structural checks do not establish it.
This is not a production recommendation to always serve an image 1040 pixels wide. A different viewport, pixel density, or design requires another decision. The experiment needs a fixed size for causal comparison. Responsive srcset and sizes should be tested separately when resource selection across screens becomes the variable.
Conditions matter as much as the file
Before execution, we froze a 1280 × 900 viewport, DPR 1, headless Chromium, a fresh browser context for every navigation, and disabled browser caching. The CDP network profile has 40 ms latency and throughput of 1,048,576 bytes per second in each direction. There is no additional CPU throttling. The collector must record the actual browser version when it runs.
This profile is a local experiment condition rather than a model of every mobile user. We must also retain hashes of the HTML, both images, and the collector. Otherwise, an unnoticed font or spacing change could change the largest element, and its effect might be incorrectly attributed to file size.
Exactly five measured navigations per variant are frozen in alternating A, B, A, B order. There are no warm-up navigations. A fresh context does not clear the operating system's file cache or every browser process cache. We therefore describe the mode precisely without promising an absolutely cold machine.
Retain a receipt for every navigation
Every navigation retained JSON Navigation/Resource Timing, paint and LCP, HTTP status, intrinsic and rendered dimensions, DOM, computed styles, geometry, console and network. No image-based UI evidence was collected. All ten documents returned HTTP 200; no console messages or failed requests were recorded.
| Layer | Observation | Limit |
|---|---|---|
| Document | Navigation Timing | Not PHP execution time |
| Image | Resource Timing and bytes | Not image decode |
| Painting | Final available LCP candidate | Candidate may differ |
| Structure | DOM, styles, geometry | Not raster quality |
Ten receipts passed the same-condition, text, structure, style and geometry checks, with no horizontal page overflow. The criterion does not demand lower LCP. The worse metric remains part of the result.
Actual numbers and their limits
Chromium 151.0.7922.34 and Playwright 1.60.0 ran the series. A delivered 18,282 image-body bytes and B delivered 6,904; Resource Timing transferSize including its accounted overhead was 18,582 and 7,204 bytes. The table lists all five observations in run order and min / median / max; times are in ms.
| Metric / condition | Five observations (ms) | min / median / max (ms) |
|---|---|---|
| navigation_ttfb_ms A | 15.1, 5.9, 3.2, 3.0, 4.2 | 3.0 / 4.2 / 15.1 |
| navigation_ttfb_ms B | 4.5, 3.6, 3.7, 3.3, 3.2 | 3.2 / 3.6 / 4.5 |
| request_to_first_byte_ms A | 5.2, 0.9, 0.6, 0.4, 0.6 | 0.4 / 0.6 / 5.2 |
| request_to_first_byte_ms B | 0.9, 0.8, 0.5, 0.6, 0.5 | 0.5 / 0.6 / 0.9 |
| image_resource_duration_ms A | 66.7, 64.7, 64.6, 62.9, 67.0 | 62.9 / 64.7 / 67.0 |
| image_resource_duration_ms B | 51.4, 56.2, 54.7, 55.0, 53.6 | 51.4 / 54.7 / 56.2 |
| lcp_ms A | 552.0, 336.0, 72.0, 72.0, 68.0 | 68.0 / 72.0 / 552.0 |
| lcp_ms B | 140.0, 68.0, 124.0, 64.0, 124.0 | 64.0 / 124.0 / 140.0 |
Median image resource duration fell from 64.7 to 54.7 ms. Median final LCP instead rose from 72 to 124 ms; candidates differed and A had substantial spread. This does not establish whether the smaller file sped up or slowed down the entire page. CDP was configured for 40 ms / 1 MiB/s, but navigation TTFB was below 40 ms: this is a setting, rather than verified latency calibration for every request. Decode duration is unavailable.
The fixture used a separate local loopback HTTP server with no external resources. Symfony, FPM, proxies and production were not checked. Two Python/Pillow source/asset checks passed separately; they do not establish browser speed.
Choose the next action from the delayed layer
If future entries show a long document wait, the next investigation should examine that path: application work, the data source, or response delivery. If the document arrives quickly while its largest visible element appears late, investigate that element's loading, scheduling, and browser work. A metric directs the search but does not replace checking a concrete cause.
Five local repetitions can show the prepared page's behavior under the declared conditions. They are not field percentiles and do not establish every reader's experience. The practical outcome of this profile is to choose one next check with a clear hypothesis, preserving the page's meaning and an honest observation boundary.
It helps to describe the page budget in words before choosing a numerical threshold: the reader should see the heading and required illustration with the same composition, and a repeated experiment must retain the same useful information. The team can then agree on specific limits for its environment and audience. A local result does not justify inventing such a threshold for a production site.
If the viewport, cache mode, or fixture file changes during repetition, those receipts cannot simply join the previous five. Start a new comparable series and retain an explanation of the change. Consistent conditions make a small experiment useful: they separate the effect of a particular delivery change from an accidental change in what the browser was supposed to display.