Chrome DevTools: Identify and visualise slow pieces of JavaScript code

Last updated: May 15, 2017
Identify and visualise slow pieces of JavaScript code

You can locate slow pieces of JavaScript code with the User Timing API.

Try wrapping potentially slow code like this:

performance.mark('costlyFunction Start')

costlyFunction()

performance.mark('costlyFunction End')

performance.measure(
	'costlyFunction',
	'costlyFunction Start',
	'costlyFunction End'
)

๐Ÿ’ก Tip: You can do much more with DevTools & the User Timing API:

  • โšก   Inject performance metrics into apps you aren't familiar with.
  • ๐Ÿ‘   Programatically read all performance measurements which have been recorded in JavaScript.
  • ๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ง   Deploy performance capturing code to your end-users so you can gather Real User Metrics.
  • โ”   Understand the benefit of Real User Monitoring, and how it compares to synthetic monitoring.
  • โš™   Use a combination of tools, like Boomerang and Node.js to receive performance metrics from your real users, straight to your servers.
  • ๐Ÿ“Š   Visualise User Timing metrics in DevTools and correlating it with existing flame graphs.
  • ๐Ÿ”Œ   Use external services & plugins to visualise your performance metrics.

The ModernDevTools.com course covers all of this ๐ŸŽŠ   and videos on these topics have been released!

There's already 50 minutes worth of video content on these topics alone and there's much more to come. I've worked hard to make information digestible. Go and check out the course! Thank you for your support.

Sign up to receive a developer tip, in the form of a gif, in your inbox each week