Created
November 20, 2012 11:36
-
-
Save JamieMason/4117426 to your computer and use it in GitHub Desktop.
Asterisk: Compare file size before/after HTML Minification & gzip
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # example usage `./asterisk_compare http://www.nytimes.com nytimes` | |
| # "http://www.nytimes.com" | |
| url=$1 | |
| # "nytimes" | |
| file_name=$2 | |
| # concat file names | |
| original="$file_name.html" | |
| minified="$file_name.min.html" | |
| # name log file | |
| log_file="asterisk-report.txt" | |
| # ensure a log file exists | |
| touch $log_file | |
| # show we're working | |
| echo "" | |
| echo "Processing $url..." | |
| # write out url as a header | |
| echo $url >> $log_file | |
| echo "------------------------------------------------------------" >> $log_file | |
| # minify original with default settings | |
| echo `asterisk --inspect --url $url --output $minified` >> $log_file | |
| # download original file | |
| curl --silent $url > $original | |
| # gzip copy of original and log size | |
| gzip --best --force $original | |
| # gzip copy of minified and log size | |
| gzip --best --force $minified | |
| # log file sizes and compression | |
| echo "" >> $log_file | |
| gzip --list $original >> $log_file | |
| gzip --list $minified >> $log_file | |
| echo "" >> $log_file | |
| echo "" >> $log_file | |
| # clean up | |
| rm $original.gz | |
| rm $minified.gz |
Author
Author
Apologies for pasting the log output twice - also worth noting that http://google.com and http://facebook.com are already minified, resulting in a degradation of performance by doing it twice.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
HTML Minification gzip size comparison tool
Compare file size before and after HTML Minification and gzipping. Minification is done using a CSS-aware HTML Minifier to ensure the layouts of the files are unchanged.
Example Usage
Output