From the course: Vanilla JavaScript: Web Performance Optimization APIs
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Detect long tasks - JavaScript Tutorial
From the course: Vanilla JavaScript: Web Performance Optimization APIs
Detect long tasks
- [Narrator] A recent addition to the performance family is the Long Task API. The long task API will let us detect when we have some code that is taking the thread for too much time, so it's a long task. And we should do something different, such as using a web worker, or changing the algorithm. That's not available in every browser today. In fact it's fairly experimental. So we need to do something similar to paint timing. This is the long task API, we also need an observer in this case, it's mandatory to have an observer. We going to create the long task observer. It's a new performance observer that we receive a list and we're going to first try to observe on that observer and in this case, the entry type is Longtask, one word. We need the catch, and we're going to observe here for now. We will just get the entries, all of them and for each entry, we're going to execute the very simple code that we'll call Perf, and we'll say Longtask and for the name, we're going to specify…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Measuring our websites4m 18s
-
(Locked)
Add the Navigation Timing API5m 7s
-
(Locked)
Use the Resource Timing API4m 45s
-
(Locked)
Create custom user timing6m 7s
-
(Locked)
Get paint timing4m 31s
-
(Locked)
Detect long tasks3m 44s
-
(Locked)
Detect frame rate drops2m 39s
-
(Locked)
Add server timing information4m 11s
-
-
-
-