Skip to content

Instantly share code, notes, and snippets.

@yuanchuan
Created May 21, 2012 11:08
Show Gist options
  • Save yuanchuan/2761842 to your computer and use it in GitHub Desktop.
Save yuanchuan/2761842 to your computer and use it in GitHub Desktop.
Quick and dirty way to check if a website is gzipped
#!/usr/bin/env node
/**
* Quick and dirty way to check if a website is gzipped
* Usage:
* ./isgzipped www.xxx.com
*/
var exec = require('child_process').exec
, site = process.argv[2];
if (site === undefined) {
console.log('missing website name.');
return;
}
exec('curl '+site+' --silent -H "Accept-Encoding: gzip,deflate" --write-out "%{size_download}" --output /dev/null', function(err, a) {
if (err) throw err;
exec('curl '+site+' --silent --write-out "%{size_download}" --output /dev/null', function(err, b) {
if (err) throw err;
console.log( a !== b);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment