Inexplicit 'task' in Chrome Perfomance DevTools

JavascriptPerformanceGoogle ChromeGoogle Chrome-Devtools

Javascript Problem Overview


Chrome exhibits huge lags when viewing a given web page of mine. I'm using the DevTools Performance tab to try and find the culprit which I assume to be somewhere in my JavaScript code.

The following screenshot shows a profile recorded using DevTools. For some of the "tasks" shown in the profile, I can see the details of what the tasks are doing (for example, the one between 8700 ms and 9200 ms is GC), but for other tasks there are no details whatsoever, like the two I have highlighted in the screenshot. How do I figure out what are those tasks doing?

Screenshot

Javascript Solutions


Solution 1 - Javascript

You can use JavaScript's performance observer to know the bottleneck of perf issues in your web app.

Precise code -

const observer = new PerformanceObserver((list) => {
    console.log('Long Task detected! 🚩️');
    const entries = list.getEntries();
    console.log(entries);
});

observer.observe({entryTypes: ['longtask']});

More details here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSergei IllarionovView Question on Stackoverflow
Solution 1 - JavascriptC AnkitaView Answer on Stackoverflow