In short and in plain language
Many shoppers click the button that puts an item in the cart. Then something should happen at once. If nothing happens, they click again.
The browser measures this wait. The value is called INP. It should be small.
The button should show right away: I am working. Only then does the page ask the server. A second click should not do things twice.
Other work waits until the button has reacted. This includes counting for statistics.
We measure the button on your pages. Then we rework it so that it reacts faster. After that, we measure again.
At the end of November, many shops find out how good their season will be, and nowhere does that show as directly as on the add-to-cart button. A shopper taps it, and for half a second nothing happens: no spinner, no counter, no cart. So they tap again. Afterwards the item may be in the cart twice, or the page only reacts to the second tap and feels sluggish. This is exactly the span the Interaction to Next Paint metric, INP for short, evaluates. The web.dev documentation explicitly names adding an item to a shopping cart as an example of an interaction that should get visible confirmation (web.dev). This article breaks the buy-button tap down into its three phases, shows how the default Shopware theme processes it and describes the levers: feedback before the server call, a lock against double taps, tracking events only after the next frame, a lean off-canvas cart and a measurement that singles out this one button.
Key takeaways
- INP measures the time from a tap to the next painted frame. Good means 200 milliseconds or less, poor means more than 500 milliseconds, measured at the 75th percentile of page loads (web.dev).
- On mobile, only 69 percent of secondary pages reach a good INP score, home pages 80 percent (Web Almanac 2025). Product pages with a buy button are secondary pages.
- The tap splits into input delay, processing and presentation. Any task over 50 milliseconds counts as a long task (web.dev) and can delay the moment the tap starts being handled.
- Only the visible feedback belongs in the click handler: a loading state in the button and a status message with
role="status". The server call, tracking events and lazy content follow after the next frame. - A double-tap lock prevents duplicate POST requests, which RFC 9110 does not define as idempotent.
aria-disabledkeeps the button in the focus order,disabledremoves it (MDN Web Docs). - Measure the button itself: in the DevTools interactions log with phases per tap, and in the field via the Event Timing API, whose observer skips entries under 104 milliseconds by default (MDN Web Docs).
What happens after a tap on the buy button
For the shopper, tapping add to cart is a single action. For the browser, it is a chain: the operating system reports the tap, the browser waits until the main thread is free, runs the event handlers and then calculates style, layout and the next frame. Only that frame shows the shopper that something is happening. INP measures exactly this stretch, from the input to the next painted frame, for clicks, taps and key presses across the entire visit (web.dev). A page counts as good if this value is 200 milliseconds or less; above 500 milliseconds the responsiveness counts as poor (web.dev). The assessment uses the 75th percentile of page loads in the field, split by mobile and desktop (web.dev). The general basics of the metric are covered in the article on optimizing INP.
What matters for the buy button is what INP explicitly does not measure. The metric is not meant to capture all the eventual effects of an interaction, such as network fetches and asynchronous UI updates, but the time during which the next paint is blocked (web.dev). Server response time therefore does not flow directly into the value. A buy button that only starts a request on tap and changes nothing else can have a good INP score and still feel broken: the next frame arrives quickly but shows nothing new. Conversely, a button with an instant loading state can score poorly if the handler keeps computing for a long time before the paint. Both belong together: the frame has to come quickly, and it has to contain the feedback.
The documentation itself shows that the cart is no edge case. Visual feedback is meant to tell the user, for example, whether an item they add to an online shopping cart is indeed being added (web.dev). Right after that, it says that for complex interactions, some initial visual feedback should appear quickly, and that the next frame is the earliest opportunity to show it (web.dev). For the buy button, that is a clear requirement: it has to look different in the first frame after the tap than it did before.
Timing adds to this. According to Chrome usage data, 90 percent of the time a user spends on a page falls after it has loaded (web.dev). The buy button sits right in that phase, and it sits on a secondary page. That is exactly where responsiveness is weaker: on mobile, 69 percent of secondary pages reach a good INP score, compared to 80 percent of home pages (Web Almanac 2025). The Web Almanac attributes this partly to secondary pages containing more complex interactions and accumulating JavaScript from third-party widgets and analytics that activate deeper in the user journey (Web Almanac 2025). A product page with reviews, recommendations and measurement scripts is exactly that case.
The three phases of a tap
Every interaction consists of three parts: the input delay until the handlers start, the processing duration of the handlers and the presentation delay until the next frame (web.dev). Their sum is the latency of the interaction. On the buy button, each of the three phases has typical causes that are easy to tell apart, and each has its own lever.
Input delay: the main thread is busy
The first phase starts with the tap and ends when the first handler starts. In between, the browser waits because the main thread is busy with something else. Any task that runs longer than 50 milliseconds counts as a long task (web.dev). On product pages, such tasks often occur in the first few seconds: scripts are parsed, compiled and executed, recommendation widgets build themselves, review boxes load in. If a shopper who already knows what they want taps the buy button during this phase, their tap waits behind that work.
web.dev also names recurring timers set with setInterval as a cause, because they are much more likely to get in the way of an input than a one-off call (web.dev). Rotating banners, countdowns for promotions and stock checks every second all fall into this group on product pages, and Black Week tends to add a few more.
Processing: too much work in the handler
The second phase covers everything the event handlers of the tap do. web.dev describes an example that closely resembles the buy button: a function validates a form, shows a spinner, sends data to the back end, updates the user interface and sends analytics, all within a single task (web.dev). Because JavaScript runs each task to completion, the browser can only paint once all steps are done. The buy button often has even more listeners: the theme, a plugin for accessory suggestions, an extension for shipping cost notices and several tracking events. Each is small on its own; together they run in the same task before the first frame.
Presentation: the cart costs layout
The third phase runs from the end of the handlers to the next frame. This is where the changes the handlers made to the DOM take effect. An off-canvas cart inserts a side panel and a dimmed backdrop, usually locks page scrolling and forces the browser to recalculate style and layout. With a large DOM this gets expensive, because rendering work grows with DOM size (web.dev). If the cart content is also inserted as HTML through JavaScript, the browser does not yield the main thread until that HTML has been parsed and rendered (web.dev).
| Phase | Typical cause at the buy button | First lever |
|---|---|---|
| Input delay | Scripts and widgets shortly after load, timers for countdowns and banners | Break up long tasks, reduce timers, load third parties later |
| Processing | Many listeners on the tap: theme, plugins, tracking | Only the visible change in the handler, the rest after the frame |
| Presentation | Off-canvas with backdrop, scroll lock, large DOM | Lean template, motion via transform, little recalculation |
How Shopware handles the tap
In the default Shopware theme, a dedicated storefront plugin is attached to the buy-button form. Its flow is spelled out in the source code: on submit, the off-canvas cart is supposed to open, the product is posted to the storefront API, and after that the current cart template is fetched and shown inside the off-canvas (Shopware). The side panel is built on Bootstrap's offcanvas component (Shopware). When it opens, Shopware removes any existing panel, creates a new one and first shows a loading indicator in it until the server response replaces the content (Shopware).
After inserting the response, the storefront fires the offCanvasOpened event, refreshes the cart widgets in the header with another request and then initializes all plugins inside the off-canvas (Shopware). For measurement, this means the tap itself ends with the frame that shows the panel with its loading indicator. The work after the server response is a separate task. It does not count toward the latency of the first tap, but it can delay the next one, for example on increase quantity or on the way to checkout.
Since version 6.7.15.0, the default buy button also shows a loading indicator inside the button that locks it until the running request is through; the storefront sets the disabled attribute for this (Shopware). The release notes give the reason explicitly: a second click should no longer be able to add the product a second time (Shopware). Since version 6.7.7.0, there is also a setting that turns off opening the off-canvas after adding to cart; the item is then added without the side panel and a success message appears (Shopware). If you run an older version or a theme with its own buy button, check whether this feedback exists at all.
In practice, the slow cases often do not originate in the core but in what is attached to it. Extensions listen to beforeFormSubmit or offCanvasOpened, themes extend the off-canvas template with accessory sliders, voucher fields and shipping calculators. What happens on the server side, for example when parallel requests of the same session wait for each other, is covered in the article on the PHP session lock in the cart; this one is about the work in the browser. How we speed up storefronts as a whole is described on the page on Shopware performance.
Feedback before the server call
The most important rule for the buy button: the handler only does what the shopper should see in the next frame. That is the loading state in the button, a short text such as "Adding item" and, where applicable, opening the panel with a loading indicator. The server call, tracking, accessory suggestions and updates to other widgets follow afterwards. web.dev recommends structuring handlers so that only the logic for the visual update runs before the next frame, and deferring everything else to a later task (web.dev). The general pattern for filters and other controls is described in the article on shop listing filters; for a custom theme with its own buy button, the skeleton looks like this:
// Buy button: visible feedback first, everything else afterwards
const form = document.querySelector('form.buy-widget');
const button = form.querySelector('.btn-buy');
const status = document.querySelector('#cart-status'); // element with role="status"
function afterNextPaint(callback) {
// Runs only after the next frame has been painted
requestAnimationFrame(() => setTimeout(callback, 0));
}
form.addEventListener('submit', (event) => {
event.preventDefault();
if (button.getAttribute('aria-disabled') === 'true') return; // second tap
// 1. Visible in the next frame
button.setAttribute('aria-disabled', 'true');
button.classList.add('is-loading');
status.textContent = 'Adding item';
// 2. Server call only afterwards
afterNextPaint(() => addToCart(new FormData(form)));
});
async function addToCart(data) {
try {
const response = await fetch(form.action, { method: 'POST', body: data });
if (!response.ok) throw new Error(String(response.status));
status.textContent = 'Item is in your cart';
queueCartEvent({ product: button.dataset.productNumber });
} catch (error) {
status.textContent = 'Not added, please try again';
} finally {
button.removeAttribute('aria-disabled');
button.classList.remove('is-loading');
}
}The pattern of setTimeout inside requestAnimationFrame looks awkward, but it reliably moves non-critical work behind the next frame in all browsers (web.dev). If you use scheduler.yield() instead, the continuation of the task is prioritized; the approach is described in the article on breaking up long tasks. The order matters more than the tool: loading state, frame, request, result, events.
Feedback also has to reach screen reader users. The W3C explanation of the success criterion for status messages uses exactly this case as an example: after a user presses an add-to-cart button, a section near the shopping cart icon adds the number of items, and a screen reader announces it (W3C WAI). An element with role="status" that is already in the DOM and whose text changes is enough. Such a status region costs hardly any computing time, but it keeps screen reader users from pressing the button and learning nothing.
Update the counter with the response
Lock double taps without losing focus
Double taps on the buy button are often not a user error but a result of missing feedback. web.dev illustrates this with an accordion: long tasks block it from opening, the user clicks multiple times thinking the experience is broken, and when the main thread catches up, it processes the delayed inputs and the accordion opens and closes unexpectedly (web.dev). On the buy button, the unlucky version is two requests, two side-panel builds and an item that sits in the cart twice.
The second tap is also tricky for measurement. If it arrives before the first one has painted its frame, the interactions overlap, and the work of the first tap lengthens the input delay of the second (web.dev). Building the off-canvas after the server response often falls exactly into this moment. The slowest tap on the page is then not the first but the impatient second one.
On the server side, the situation is clear: a POST request is not idempotent. A method is idempotent if multiple identical requests have the same intended effect on the server as a single one; of the methods defined in the HTTP specification, that applies only to PUT, DELETE and the safe methods (RFC 9110). Two identical requests to the cart route may therefore have two effects. The lock belongs in the browser, and a second safeguard on the server does no harm.
There are two ways to lock the button in the browser. The disabled attribute disables a button completely; aria-disabled conveys the state to assistive technology but does not change focusability, so the button is not removed from the tab order (MDN Web Docs). MDN explicitly names a button that should stay in the focus order while its action is presently unavailable, such as submitting a form, as a use case (MDN Web Docs). Because aria-disabled does not block the click by itself, the handler checks the state, as in the skeleton above. Keyboard users keep their place on the page while the button is briefly locked.
- Lock before the first request: set the state in the handler before the server call is scheduled, not in the request callback.
- Release on failure too: if the request fails, the button must become usable again, otherwise the lock turns into a dead end.
- One lock per form: on pages with several buy buttons, such as listings, each button locks only its own form.
- Safeguard on the server: a token per submission or a short lock per session and item catches whatever slips through in the browser.
How the loading state in the button looks, whether a spinner, a checkmark or a text change, is a design question. For speed, what counts is that it appears in the first frame after the tap and disappears again if the request fails.
Tracking events only after the frame
For many shops, the buy button is one of the most important measurement events. Accordingly, many scripts listen to it: web analytics, advertising platforms, recommendation services, sometimes a tag manager with its own rule chain. Each of them serializes product data, builds event objects and calls its own listeners. If these calls run synchronously in the click handler, they lengthen the processing duration of exactly the interaction that matters.
The solution is an order, not a sacrifice: first the frame with the feedback, then the server call, then the events. For non-urgent work, the Prioritized Task Scheduling API provides the background priority, intended for tasks that are not time-critical, such as log processing (MDN Web Docs). Where scheduler.postTask() is missing, the pattern with requestAnimationFrame and setTimeout does the same job:
// One shared event for all measurement scripts, at low priority
function queueCartEvent(detail) {
const send = () => window.dispatchEvent(new CustomEvent('shop:cart-added', { detail }));
if (globalThis.scheduler?.postTask) {
scheduler.postTask(send, { priority: 'background' });
} else {
requestAnimationFrame(() => setTimeout(send, 0));
}
}
// Measurement scripts listen here, no longer on the buy button
window.addEventListener('shop:cart-added', (event) => {
// Hand the event to your own analytics
});The advantage of a dedicated event: all measurement scripts listen to exactly one place, which only fires once the feedback has been painted and the server response has arrived. The event then only reports items that are actually in the cart instead of every tap. Which scripts need to run on the product page in the first place is clarified by an inventory like the one in the article on trimming third-party scripts.
A note on the order: events that only fire after the server response arrive a little later than before. For reporting, this usually makes no difference as long as the shopper stays on the page, which they do with an off-canvas cart. If the buy button leads directly to the cart page instead, sending needs a way that survives the page unload, or the event is fired on the cart page.
Render the off-canvas cart lean
The off-canvas cart is the visible answer to the tap, and it is often heavier than necessary. In many themes it contains, besides the line items, an accessory slider, a voucher field, a shipping cost estimate, delivery time notes and trust badges. Each of these elements brings DOM nodes and often its own JavaScript, which the storefront initializes after inserting the response (Shopware). Five adjustments help here:
- Insert accessories later: load suggestions only once the line items are in place, and limit them to a few products. A slider with many cards rarely pays off in a narrow panel.
- Images with fixed dimensions: deliver product images in the cart at a suitable width and with
widthandheight, so the panel does not jump when they load. - Motion via transform: slide the panel in with
transform: translateX()instead ofleft,rightorwidth. To move an element, web.dev recommends thetransformproperty withtranslate(web.dev). - Reuse the panel: Shopware removes an existing panel on opening and creates a new one (Shopware). In a custom theme, a panel created once and kept hidden, which only swaps its content, can be faster; the measurement shows whether it is worth it.
- Skip what is off-screen: parts outside the visible area can be excluded from rendering with
content-visibilityuntil they are needed (web.dev).
Part of the work lies outside the panel: the larger the DOM of the product page, the more expensive every recalculation triggered by opening it. How to slim down a heavy mega menu that ships with every product page is described in the article on the mega menu as a speed brake. We handle the rework of templates, scripts and styles as part of our front-end optimization.
Measure with the interactions log
In the lab, the Performance panel of Chrome DevTools is the fastest route. When opened, it immediately shows local values for LCP and CLS, captures the INP value after an interaction and lists every captured interaction with element, timings and phases in its Interactions tab (Chrome for Developers). For the buy button, three taps belong in the log: one right after load while scripts are still running, one after a few seconds of rest and a quick double tap. The documentation also recommends throttling CPU and network to get closer to your users' devices, and gives a 20x CPU slowdown as an example (Chrome for Developers). How the live view works in detail is shown in the article on live metrics in DevTools.
In the field, the Event Timing API provides the raw data. A PerformanceObserver for entries of type event only reports entries from 104 milliseconds by default; the threshold can be lowered via durationThreshold, is rounded to the nearest multiple of 8 milliseconds and is at least 16 milliseconds (MDN Web Docs). The following snippet logs every captured tap on the buy button with its three phases to the console:
// Run in the console of a product page, then click the buy button
const observer = new PerformanceObserver((list) => {
for (const entry of list.getEntries()) {
if (!entry.interactionId) continue; // real interactions only
if (!entry.target?.closest?.('.btn-buy')) continue; // the buy button only
console.table({
event: entry.name,
total: Math.round(entry.duration),
inputDelay: Math.round(entry.processingStart - entry.startTime),
processing: Math.round(entry.processingEnd - entry.processingStart),
presentation: Math.round(entry.startTime + entry.duration - entry.processingEnd),
});
}
});
observer.observe({ type: 'event', durationThreshold: 16, buffered: true });For continuous measurement in the field, the attribution build of the web-vitals library provides, for each INP value, the triggering element as a CSS selector, the type of interaction and the three phases as separate fields (web.dev). Grouped by selector, this shows whether the buy button determines the INP value of the product page. That is likely, because product pages tend to have few interactions: only with many interactions is the slowest one ignored for every 50 interactions, otherwise the slowest of all usually counts (web.dev).
How field data from your own measurements and from the Chrome User Experience Report work together is covered in the article on RUM and CrUX, and finding the responsible function in the article on Long Animation Frames. If you would rather hand off the measurement: in our technical analysis we measure the buy button on your product pages with a throttled CPU, evaluate the interactions log and compare it with field data.
Checklist before Black Week
Between the publication of this article on November 16 and Black Friday on November 27, there are eleven days. The following steps can be implemented and verified in that time without rebuilding the purchase flow:
- Measure the buy button on a typical product page three times with a throttled CPU: right after load, after a pause and as a double tap.
- Identify the largest of the three phases in the interactions log and start there.
- List all listeners on the form and on
offCanvasOpened, and decide for each whether it has to run before the next frame. - Switch tracking events to one shared event after the server response.
- Add the double-tap lock and test the failure case, for example with the network switched off.
- Declutter the off-canvas template: limit accessories, give images dimensions, use
transformfor motion. - Repeat the same three measurements after the rework and watch the field value of the product pages for at least one week.
Shortly before a high-revenue week, a small, measurable change to the buy button makes more sense than a major theme rebuild. If you also want to look at the checkout, you will find the steps after the cart in the article on checkout speed. Our services around Google's user experience metrics are bundled on the page on Core Web Vitals.
Sources and documentation
disabled attribute, however, removes the button from the focus order, while aria-disabled keeps it there (MDN Web Docs). Because a POST request is not idempotent (RFC 9110), an additional safeguard on the server is worthwhile.Related Articles
Oversized Images Despite srcset: Getting sizes Right
Browser still loading the big file despite srcset? Usually sizes is missing or no longer fits the grid. How browsers pick files, how to derive and check sizes.
Reading the network waterfall: what each row reveals
Learn to read the network waterfall: how it is ordered, what the phases of a bar show and which six patterns across rows reveal typical slowdowns.
WordPress Slow Despite Caching: WP-Cron and admin-ajax
Page cache on, WordPress still sluggish? WP-Cron, Heartbeat and admin-ajax bypass the cache and tie up PHP workers. How to measure that load and take it off.