I'd like to instrument some timing variables for my main JavaScript load. I could do something like this:
<script>
performance.mark('script-start')
</script>
<script src="something.js"></script>
Then somewhere in something.js add a performance.measure('script-start')
.
The problem is that this would time both the script download time and the script parsing and (part of) the execution time. Is there a way to time script download and execution separately?
Put performance.measure('script-start')
at the very beginning of something.js
. This will include the parse time, but not the execution time. Unless the script is enormous, the parse time should be almost negligible.
You could time the download and execution separately by putting performance.mark('download-start')
in the first <script>
tag. Then put
performance.measure('download-end');
performance.start('script-start');
at the beginning of something.js
.