"This page is slow" is not a work instruction. Slow compared with what, for whom, at what moment? Optimisation without measurements produces changes that complicate the code and do not change what the user perceives. The method is the opposite: you start from a number, find where the time goes and act there.
The cycle
1. A measurable goal. A performance requirement has a number and a context: "the order list opens in under a second with ten thousand rows, on an average connection". For the web there are standard indicators of perceived quality, the Core Web Vitals (how fast the main content appears, responsiveness to interactions, layout stability); the reference values must be taken from the current official documentation.
2. Measure the current state. Without an initial measurement you cannot know whether you have improved. You measure under real conditions or as close as possible: production data (anonymised), representative devices and networks.
3. Find the bottleneck. You profile: where does the time go? Often it is not where you think. In the frontend: file size, resources that block rendering, unoptimised images, needless re-rendering. In the backend: slow or repeated queries, missing indexes, synchronous operations that could be deferred.
4. Fix one point at a time. You act on the biggest bottleneck, not on everything. Each change is measured on its own.
5. Measure again and compare. You compare with the initial measurement. If there is no significant improvement, the change is undone: the added complexity is not justified.
6. Protect the result. You add a check (a threshold in tests or in monitoring) that warns if performance gets worse again.
The most common culprits
- N+1 queries: one for each item in a list, instead of one for the whole list.
- Lists with no limit or no pagination.
- Missing indexes on columns used to filter or sort.
- Excessive payloads: heavy images, whole libraries to use one function.
- Repeated work: identical calculations or requests redone on every request, where a cached result would do.
- Needless re-rendering of the interface.
Optimising with judgement
An optimisation has a readability cost. You do it when there is a requirement not being met, or a measurement showing a real problem. Premature optimisation, done "to be safe", makes the code harder to understand with no demonstrated benefit.
Warning signs
- Optimising without a starting measurement.
- Acting on what "looks slow".
- Several optimisations at once: you do not know which one worked.
- No check that stops the problem coming back.
- Sacrificing readability for an unmeasured gain.
An example
A list opens in four seconds. The profile shows that almost all the time goes on hundreds of small queries, one per customer. They are replaced by a single query that brings the customer data with it: the time drops under a second. A test is added that flags if the number of queries per page goes over a threshold.
When to use it
When there are performance requirements, when a regression is suspected, when Core Web Vitals or load times need to improve, or when a profile has identified a bottleneck to fix.
This method derives from the open-source agent-skills family by Addy Osmani (MIT licence), rewritten and adapted.
This article is an OIAR skill
What you have just read is the content of a skill from the OIAR catalogue, written for people. Knowledge like this, but richer and deeper, written for the agents, drives the interviews, the analysis and the report inside the platform. Skills are used in OIAR: to try this one on a project of yours you need an account.
performance-optimizationA method for improving performance without guessing: a measurable goal, an initial measurement, profiling, fixing the bottleneck, measuring again, a guard against regressions. Use it when there are performance requirements, suspected regressions or load times to improve.