Javascript Compression Performance Testing

I used 5 JavaScript compressors to compress the JavaScript library (JSMin, YUI compressor, Packer, closure compiler, and UglifyJS)

Now I know that the closure compiler is a winner in file size reduction. However, I also want to check the performance gain. What would be a good way to do this?

I made a simple test page that uses all the public methods of the library. Is there a tool to check the page speed of this test page? For instance. run it X times in the browser and return the average download speed.

Thank you for your responses!

+6
source share
4 answers

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.

+1
source

I suspect the PageSpeed ​​tool is what you are looking for.

0
source

Use the PageSpeed ​​or YSlow parameter in firefox or HTTPAnaylser for IE to check the time difference.

0
source

It really depends on the fact that your audience cares most about the site. Time to appear on the screen? Time to download? Animation smoothness? Interactive responsiveness? Or raw calculation speed?

You should profile your site compressed with minifiers based on the most important metrics.

Side note: The Closure compiler provides minimal acceleration in simple mode. It reduces the file size, but the JavaScript program remains the same. To achieve significant code reduction and speed optimization, you need to use advanced mode.

0
source

Source: https://habr.com/ru/post/888883/


All Articles