madrobby/microjs.com — pull request #201 by rvagg (2011-12-17 12:07:10+00:00)
Title: Size checker has grown up

Once I start I find it difficult to stop! I decided to use this to experiment a bit with some node stuff and now it's completely rewritten.

The diff & README should make it relatively clear what I've done, but in summary:

* fixed most of the URLs, they are now all **unminified** raw sources
* let `source` contain actual JS (for very small libs), arrays of sources, or zip files with bang-paths to the zip entry of the source (I thought having GitHub locations pointing to source directories to be scraped would be cool, but really, just make a single source file available!).
* it now builds `data-min.js` for you, `make compile` does all the work. There is also `./build -v` to see a more verbose output.
* The output contains an extra `sizes` attribute on each entry which looks like this: `{"raw":745,"minified":368,"gzipped":222}`. These are bytes and I thought this could be used on the interface in some fancy way, perhaps a hover-reveal of the 3 sizes. But of course they are not necessary and they add to the size of the data file so they could easily be removed. See *lib/main.js*, `success()`.
* Enforced the 5k limit, this is up to you of course, you'll note that it knocks Zepto out which you may not be happy about. See *lib/validator.js*.
* It enforces the requirement to have an unminified source, but this is not strictly necessary if the `sizes` attribute (above) isn't going to be used on the page. See *lib/validator.js* for this also.
* Some tweaks to *index.html*, the `location.href` change was just to get it working from a `file:///` URL, but I didn't cross-browser check that. Some minor style tweaks, I hope you're cool with that, I'm not known for my stylin'.
* README tweaks.

Also, the `size` attribute in *data.js* isn't strictly necessary now, in fact I'm pretty sure if you left it off it would run OK. But I've left it there and clarified it on the README because it's a handy sanity check, IMO.

Cheers, now I must sleep.