Ben Schwarz
September 15, 2022
Illustrated by
Blinking takes approximately 100–400 milliseconds. That’s fast, but it’s two to eight times longer than most people will accept when interacting with a rendering web page. Any longer than 50 milliseconds and visitors sense that a page is unresponsive, affecting their overall user experience.
To reduce that feeling of unresponsiveness, you need to improve your Total Blocking Time (TBT) metric. TBT tracks how long a page’s main thread is blocked by long tasks (any tasks longer than 50 milliseconds) during the loading process. Long tasks lock up the main thread and delay user inputs, which gives the appearance of an unresponsive page.
By following this Total Blocking Time guide you will learn how to implement fixes and track results towards improvement. More experienced developers will have more fixes available to them, but even beginners will make a meaningful impact on their site speed and user experience by following this guide.
TBT is calculated like a running clock. Any time a single task exceeds a 50-millisecond threshold, the clock starts and runs until that task is finally complete. Total Blocking Time is the sum of these long tasks (minus each of their first 50 ms) that occur between First Contentful Paint and Time to Interactive.
For example, consider these two lists of tasks.
Task List 1:
Task length | Task length above 50 ms (contributing to TBT) | |
---|---|---|
Task 1 | 40 ms | 0 |
Task 2 | 60 ms | 10 ms |
Task 3 | 50 ms | 0 |
Task 4 | 55 ms | 5 ms |
Task 5 | 75 ms | 25 ms |
Total time: 280 ms | Total Blocking Time: 40 ms |
Task List 2:
Task length | Task length above 50 ms (contributing to TBT) | |
---|---|---|
Task 1 | 140 ms | 90 ms |
Task 2 | 140 ms | 90 ms |
Total time: 280 ms | Total Blocking Time: 180 ms |
Both task lists take the same amount of processing time. However, because Task List 1 has five shorter tasks, its TBT is much lower. In contrast, the two long tasks on Task List 2 spend much time above the 50 ms threshold, so it has a comparatively high TBT.
Reducing your page’s TBT is vital because the long tasks it measures can delay user input and make your page feel unresponsive. Your page’s main thread only handles one task at a time, so a particularly long task delays everything else, including user inputs. The shorter your TBT, the more responsive your page feels to visitors.
A good TBT score is less than 300 milliseconds, so consider that an initial goal for all your top pages. Use tools like Calibre or Lighthouse to see your page’s TBT. Then, use this data to track how changes to your site improve or degrade your page’s TBT and other user-focused metrics.
There are several ways to make improvements to your TBT, and not all of them are complex. Below you’ll find the best ways to make improvements, plus tips on how to implement them successfully.
JavaScript is one of the biggest causes of slowdowns on the main thread. Any way you reduce the file size or runtime of your JavaScript will improve your TBT numbers.
Some ways to accomplish this are by:
Third-party scripts quickly destroy your speed metrics by clogging up the main thread with tasks that aren’t critical to your web page. Take these steps to prune those back and prioritise what needs to be loaded right away.
Much of the essential work you do to reduce work on your main thread should already be done if you’ve followed the first two steps. However, you can always do more to keep your main thread fast. Here are some more advanced tips for keeping your main thread clear of large tasks.
Making quick fixes and walking away isn’t a good solution for better long-term site speed. After putting in any of these optimisations, you should track the results and see how you can take that next step towards being that much faster.
Calibre allows teams to track page speed metrics across multiple domains to see how their performance changes over time. It also gives you access to nifty tools like third-party tracking and performance budgets to stay on top of metrics like Total Blocking Time. Calibre gives you full access to all of our features for free for 15 days. Use those 15 days to give your TBT a tune-up and see how much easier it is to do with a page speed–monitoring tool like Calibre.
Join thousands of subscribers keeping up-to-date with web performance news and advice.
Addy Osmani
Engineering Manager at Google Chrome