The Long Animation Frames API (
long-animation-frame entries)Long Animation Frames (LoAF) entries report any frame delayed by more than 50 ms. Each entry has a scripts list showing the script's sourceURL, the function that started it, and how long it ran. That points you to the guilty code.
"The Long Tasks API" is the tempting wrong answer. It reports that a long task happened, but it gives almost no detail about which script ran. Resource Timing and Navigation Timing measure downloads and page load, not main-thread work.