Inexplicit 'task' in Chrome Perfomance DevTools
JavascriptPerformanceGoogle ChromeGoogle Chrome-DevtoolsJavascript 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?
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