A save you can see land
Turning an invisible wait into something you can follow.
The invisible wait
Press save and your data leaves on a trip nobody can see. If the button stays still, people assume it did not work, so they press it again. The demos in this article simulate a server, so you can feel each delay safely.
Requests sent: 0. Finished: 0.Every press sends another request. In a real product, that could mean duplicate records, repeated payments or a confused server. The problem starts with missing feedback.
Answer the press
The first job is to respond the moment someone presses, and to ignore repeat presses until the work is finished.
Requests sent: 0.Notice that we use aria-disabled instead of disabled. A truly disabled button loses keyboard focus, which drops keyboard users back to the start of the page in the middle of their task.
</> A single flag stops the duplicates.Show code
let saving = false;
button.addEventListener('click', async () => {
if (saving) return;
saving = true;
button.setAttribute('aria-disabled', 'true');
try {
await save();
} finally {
saving = false;
button.removeAttribute('aria-disabled');
}
});Do not flash a spinner
A spinner sounds like the obvious answer. On a fast connection, though, it appears and vanishes before anyone can read it, and that flicker makes a fast save feel broken. Two small timers fix it.
Wait 300 ms before showing it, so quick saves never show one. Then keep it visible for at least 500 ms, so it never blinks. These numbers are good starting points, and you can tune them for your own product.
Progress that tells the truth
Most requests cannot report real progress, so bars are often faked. A timed bar reaches the end whether the work is finished or not, then sits there at 100% while you wait.
Left: a fixed two second timer. Right: a curve that slows down and only finishes when the server replies.
The curve on the right moves quickly at first, then gets slower and slower without ever reaching the end. Only a real response can complete it, so the bar can never claim to be finished early.
</> Approach the end, but never touch it.Show code
const progress = finished
? 1
: Math.min(0.94, 1 - Math.exp(-elapsed / patience));
bar.style.transform = `scaleX(${progress})`;The landing
This is the moment the article is named after. Success should be felt as well as read. The button absorbs the impact, changes colour, and draws a tick as the word changes.
One level deeper. The button keeps the same width in every state, so nothing around it shifts when the text changes. The tick is one path whose stroke-dashoffset animates to zero, and setting pathLength="1" means we never need to measure it.
</> The tick draws itself.Show code
<path pathLength="1" d="m4 10.5 4 4 8-9" />
.tick {
stroke-dasharray: 1;
stroke-dashoffset: 1;
}
[data-state="done"] .tick {
stroke-dashoffset: 0;
transition: stroke-dashoffset .45s ease-out;
}When it does not land
Saves fail. A good failure is calm: it says what happened, keeps everything the person typed, and offers the next step right where they are already looking.
The text in the field stays exactly as it was. The message sits in a role="status" region, so screen readers announce every change without moving the person’s focus.
Do not wait at all
For small, low-risk actions, the fastest save is one that does not make you wait. An optimistic interface shows the result immediately and quietly confirms it in the background.
If the server refuses, the star moves back with a small shake so the change is noticed. Optimistic updates suit likes, stars and reordering. Payments, deletions and anything hard to undo should always wait for confirmation.
</> Update first, and keep a way back.Show code
const previous = item.starred;
item.starred = !previous;
render();
try {
await saveStar(item);
} catch {
item.starred = previous;
render();
showError('Your star could not be saved.');
}