Explore Bato Web Agency Webflow Certified Partner Profile Explore Bato Web Agency Webflow Certified Partner Profile

[Violation] ‘click’ handler took 3000ms — how do I find the slow code?

Illustration without a description Illustration without a description

Chrome logged a long main-thread task associated with a click. Record the interaction in the Performance panel and inspect that task’s call tree. The cost may come from JavaScript computation, parsing or a large layout update triggered by the handler.

 

Move suitable computation to a worker or split work into smaller tasks when profiling shows that is where time goes. If the trace shows repeated layout work, inspect where the handler alternates between reading geometry and writing styles. Use the trace to choose a change you can measure.

 

Compare performance.now() inside the handler with the full trace, which also shows the rendering work around the click. Compare that measurement with the full browser trace, which can show rendering work too. Record the same interaction again after the change and see whether the page responds sooner.

 

document.querySelector('#action')?.addEventListener('click', () => { const start = performance.now(); // Run the actual handler work here. console.log('Handler time (ms):', performance.now() – start); });

 

Record one slow click and use Bottom-Up to find where the handler and its callees spent the most time.