No need to be complicated:
<html> <head> <script> var time = new Date(); </script> <script src="..."></script> ... more scripts ... </head> <body> <script> document.write("Time: " + String((new Date() - time)/1000) + " seconds"); </script> </body> </html>
Scripts in <head> are usually loaded in batches, so this should be a reasonable method for measuring the execution time of a script. If you have scripts that execute the form <body onload="..."> , then calculate the elapsed time at the end of this function, not the end of the body.
This method will not determine the runtime for "asynchronous" functions executed via setTimeout or setInterval , but they should not take into account the load time.
An alternative alternative and probably simpler option is to use the built-in javascript profiler for the Chrome or Safari web inspector.
source share