Core Web Vitals

Measure LCP after prerender activation

Use explicit clocks, lifecycle checks and synthetic cases to validate LCP after prerender activation.

Two small browser windows sit above a timeline with a hollow start marker, a teal activation marker, and a short mint segment ending at a paint marker.

Measure a prerendered page's LCP from activation, when the prepared document becomes the page the visitor actually opens. Keep the browser's original timestamps for diagnosis, but do not mistake time spent preparing a hidden document for time the visitor waited after navigating.

Establish which clock your dashboard uses

A prerender can start before a visitor follows a link. The browser prepares a separate document in the background and may activate it later. A measurement taken from that document's original time origin therefore answers a different question from a measurement of the visible navigation. Mixing the two can make a successful prerender look slow, or make an incorrect collector look exceptionally fast.

Start the investigation at the event schema, before changing the page. Find the field your dashboard calls LCP and identify who calculated it. Is it the value supplied by a maintained measurement library, a raw performance entry's startTime, or a value transformed by your own analytics pipeline? Record that answer beside the field name. A generic column called duration is not enough to audit the calculation.

The distinction matters even when a chart looks plausible. An activation adjustment applied twice can collapse valid measurements to zero after a clamp. A missing adjustment can include seconds of speculative preparation. Neither error is repaired by compressing the hero image. First establish what the number measures, then investigate rendering if the corrected experience remains slow.

Recognize activation without confusing it with visibility

During prerendering, supporting browsers expose document.prerendering as true. After activation it becomes false, so checking only its current value can miss a document that was prerendered earlier. The navigation timing entry's activationStart provides the complementary signal: a positive value indicates when the previously prerendered document was activated, relative to its original time origin.

The property is zero for an ordinary navigation and while prerendering is still in progress. Missing support is another case, which should remain distinguishable from a supported zero. For a diagnostic export, preserve both whether the property exists and its numeric value. This avoids turning an unsupported observation into supposed evidence that prerendering never happens on a particular device.

Use the Chrome documentation on prerendering and measurement to check the lifecycle your implementation relies on. Native PerformanceNavigationTiming.type does not provide the same classification as a measurement library's navigationType. In particular, the library can report prerender even though the native navigation type is not a prerender-specific value.

A background tab is also not automatically a prerender. Opening a link in another tab, switching away during loading and activating a speculative document are different situations. Do not replace all their timestamps with the time of the next visibility change. Keep the lifecycle rules in the collector rather than trying to infer them afterward from a single hidden-state flag.

Keep library output and raw entries separate

The maintained web-vitals implementation adjusts LCP for prerender activation. Its LCP calculation uses the candidate entry's timestamp minus activation time and clamps the result at zero. That describes one part of its work; candidate selection, visibility handling and reporting lifecycle still matter. Recreating that single subtraction does not create an equivalent complete LCP collector.

If you already receive the library's metric value, store that value as reported. Do not subtract activationStart again in a tag manager, warehouse transformation or visualization. Use separate diagnostic columns for the original timing entry and activation time, with names that make their reference point explicit. Preserve the library version so a later comparison can identify instrumentation changes.

This module illustrates a small local diagnostic record in an application that installs and bundles a compatible web-vitals release. It logs the normalized metric rather than implementing LCP itself. The code stays deliberately separate from transport, consent handling and storage policy.

js
import { onLCP } from 'web-vitals';

onLCP((metric) => {
  const navigation = performance.getEntriesByType('navigation')[0];
  const supported = !!navigation && 'activationStart' in navigation;

  console.table({
    metricId: metric.id,
    lcpMs: metric.value,
    navigationType: metric.navigationType,
    activationSupported: supported,
    activationStartMs: supported ? navigation.activationStart : null
  });
});

Initialize the observer once per document through your application's measurement entry point. Repeated initialization by several components makes the output harder to interpret. If your existing collector reports updates, preserve its metric identity and update semantics when sending records onward. This guide's activation check should not quietly replace the established ingestion rules.

Test the arithmetic with explicit synthetic cases

Before using production traffic to validate the pipeline, write down a few made-up timestamp pairs. These examples are arithmetic checks, not measured results or suggested performance budgets. They help identify whether a transformation receives raw timestamps or already normalized values.

Synthetic case Candidate timestamp Activation timestamp Activation-relative result
Ordinary navigation 1,600 ms 0 ms 1,600 ms
Candidate after activation 4,250 ms 4,000 ms 250 ms
Candidate before activation 2,500 ms 4,000 ms 0 ms after clamping

For the middle row, an already normalized library value is 250 ms. Subtracting 4,000 ms from that value is an error. Equally, displaying 4,250 ms as the visible waiting time ignores the preparation period. Label the inputs in any test fixture so the same numbers cannot pass through two incompatible transformations without detection.

A zero in the final row does not mean the document required no network or CPU work. It means that the timing calculation places the candidate before activation. Investigate an unexpected cluster of zeros by comparing raw inputs and code paths, not by deleting all zero values. Discarding legitimate fast observations would introduce another measurement error.

Keep synthetic fixtures outside the live performance dataset. They belong in validation and monitoring tests with unmistakable labels. Otherwise a useful debugging tool becomes a source of artificial visits, particularly when a small route has little traffic and a few test records noticeably influence its distribution.

Exercise the actual navigation path

Test a normal direct navigation first and save its classification, activation support and LCP record. Then exercise a supported prerender path from a source page, allowing enough time for preparation before following the link. Confirm that activation occurred using the destination's navigation timing data. The presence of speculation instructions on the source page alone does not prove that the browser acted on them.

Repeat with a short delay before following the link, so the destination can activate while work is still unfinished. This tests a materially different case from a fully prepared document. Also test an abandoned candidate that is never opened. Your ordinary page-view analytics should not count background preparation as an actual visit merely because code executed in that document.

Review initialization code that waits for activation. On a document still prerendering, prerenderingchange can trigger the activity when activation happens. On a document already activated before the code loads, waiting only for a future event leaves the activity uninitialized. Check the present state first and retain an immediate path for documents that no longer need to wait.

Include one unsupported environment and one background-tab scenario in the test notes. The desired outcome is correct classification and graceful collection, not forcing every navigation into the prerender bucket. Keep the page content and viewport comparable across tests, because a changed candidate makes a timing difference harder to attribute to activation alone.

Compare distributions with their traffic mix

After deployment, inspect prerendered and ordinary navigations separately before reading the combined chart. Compare like routes, devices and content variants. A growing share of already prepared pages can improve the overall distribution without changing the ordinary-navigation experience. That is useful information, but it is a different result from making the server or rendering pipeline faster for every visit.

Report sample counts and the observation period beside each comparison. Do not average the two groups' 75th percentiles to manufacture an overall percentile. Calculate the combined statistic from the underlying observations using the intended population. If coverage differs across browsers or collection versions, document that difference rather than interpreting the gap as a performance effect.

The good LCP threshold remains 2.5 seconds at the 75th percentile. It applies to the user-facing metric, not to the speculative preparation timestamp. Use the field and laboratory data guide when a direct lab navigation and real-user results differ; they may represent different navigation paths as well as different devices and networks.

Close the audit with a reproducible record

Keep a short record containing the tested route, browser version, collector version, candidate description, activation classification and raw-versus-normalized field definitions. Include one ordinary-navigation sample and one confirmed activation sample. This gives the next maintainer enough context to detect a schema regression without repeating the entire investigation.

Finally, separate measurement correctness from the decision to expand prerendering. Prepared pages consume resources even when no visitor opens them. Track the useful activations and wasted preparation alongside the performance distribution before broadening the rules. A clean LCP chart cannot by itself establish that more speculation is worthwhile. The finished audit should show that visible waiting time is measured consistently and that ordinary visits remain visible in the report.

Related guides