Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

67
Views
Is there a way to time script download time separately from execution?

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?

7 months ago · Juan Pablo Isaza
1 answers
Answer question

0

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.

7 months ago · Juan Pablo Isaza Report
Answer question
Find remote jobs