Safari 4: How to profile the code running when the page loads
Question
In Safari 4, I am trying to use the profiler to see how the time is spent in the code that runs when the page loads.
- I enabled the profiler ("Start profiling JavaScript")
- I load the page.
- I stop the profiler.
At this point, this doesn't create a "profile" snapshot (while it does if I start the profiler after the page is loaded). Any hint on this?
Solution
For code inside onLoad handlers, you need to enable the profiler programmatically. Add console.profile() to the start of the relevant javascript, and console.profileEnd() to the end.
Read more here: Using the Web Inspector
It's very similar to FireBug's profiler: Console API
Update: The Web Inspector link above 404s. Here's a more current document: Web Inspector Guide: Timelines
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow