FE4: Measuring speed

Lesson 5 of 5 ยท reading 15โ€“25 minutes; practice and project time is on the module page

Fixing slow responses to taps

๐ŸŽฏYou'll be able to

Find and fix slow responses to taps and typing so INP stays within 200 ms.

๐Ÿ The everyday picture

At a ticket counter, if the clerk finishes filling a long form for one person before even looking up at the next, everyone waits. A good clerk acknowledges each person straight away and finishes paperwork in between.

๐Ÿ“˜What it really is

๐Ÿ“A worked example

Kirana's "Add to cart" tap took 220 ms because it recalculated every offer for the whole cart before updating the badge.

Change Tap to visual update
Starting point 220 ms
Update the badge and button immediately; recalculate offers in a transition 60 ms
Load the chat widget only when "Help" is tapped 45 ms; start-up main-thread time down by 400 ms

Field INP moved from 180 ms to 110 ms at the 75th percentile.

๐ŸŒWhere it's used

๐Ÿ“Case scenario

After marketing adds three new tracking tags, complaints arrive that the checkout button "doesn't work the first time". The Performance panel shows the tags running long tasks just as the page becomes visible, so early taps wait. Loading the tags after the page is interactive and removing one unused tag restores quick responses, and the team agrees a review step for new third-party scripts.

๐Ÿ–ฑ๏ธTry it

Find the slowest interaction on your Kirana app with the Performance panel. Apply one of the techniques above, and record the time from tap to visual update before and after on a throttled CPU.

โš ๏ธCommon mistakes

๐Ÿ› ๏ธFor your project

The starter deals page ranks products with a heavy loop on each change; Project 3 asks you to bring its interaction under 200 ms.

โœ…Quick check

Name two ways to improve INP.

Show the answer

Break up long tasks, give visual feedback first and defer slower work, or delay third-party scripts.

What does useTransition do?

Show the answer

It marks a state update as non-urgent, so urgent updates such as typing stay responsive.

โ† PreviousFixing slow loading and jumping layouts
ProLearners Assist