Speed

Performance: Making It Fast

People decide whether your app is any good in the first couple of seconds, and they are not generous about it. Slow reads as broken.

The good news: for a small app, slowness is usually one of about five things.

Measure first

Never optimize by guessing — you will spend an afternoon speeding up something that was never the problem.

Open your browser's developer tools and look at the Network tab. Reload the page. You get every file, its size, and how long it took. The offender is usually obvious and usually enormous.

The usual suspects

1. Giant images. Far and away the most common. A photo straight from a phone camera can be several megabytes; the same picture, resized to what the page actually shows, might be a few dozen kilobytes. Same image, twenty times smaller.

2. Everything loading before anything shows. If the browser must fetch every script before drawing the page, visitors watch a white screen. Scripts that are not needed immediately should not block the first paint.

3. Loading a whole library for one function. AI code does this a lot — pulling in a large package to format a date. Ask what each dependency is for and whether a few lines would do.

4. Doing work over and over. Redrawing an entire list because one item changed is fine with ten items and painful with a thousand.

5. Timers nobody stops. Something set to run every second, started again each time you visit a screen, never canceled. It gets slower the longer the app is open — the classic "fine at first, sluggish after ten minutes".

The phone test

Your laptop on home wifi is the best case, and almost nobody is in the best case. Most browsers can pretend to be a slower device on a slower connection — use it. It is humbling and it is honest.

A word on "optimizing"

Do not restructure working code for speed you have not measured. Complexity is a real cost, paid every time you or an AI touches that file later. Fix the measured problem and stop.

Go deeper

Why Your AI App Is Slow goes through each cause with specifics.