Skip to content

Instantly share code, notes, and snippets.

@sindresorhus
Created October 24, 2012 19:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sindresorhus/3948386 to your computer and use it in GitHub Desktop.
Save sindresorhus/3948386 to your computer and use it in GitHub Desktop.
grunt-contrib task proposal

grunt-contrib task proposal

We intend extract the tasks included in Yeoman to make the project more modular and be a good internet citizen. We've already done so with the Compass task.

I've added some tasks that might be fitted for grunt-contrib.

grunt-contrib-img

Optimizing images is something most projects need. I think it's important grunt-contrib has a simple and opinionated task for this.

When we created the Yeoman img task I researched the best tools out there. We didn't want to complicate the setup with a lot of different minifiers and ended up with OptiPNG and jpegtran from the libjpeg-turbo package, both working cross OS, actively developed and super fast.

There already exist a grunt plugin for optimizing images, but it's too flexible and I would like something that is super simple to set up and use without having to change a single setting, of course you can if you want.

This task would require dependency on both optipng binary and jpegtran, but I'm going to work around that by creating a couple of wrapper node modules embedding those. This would mean it would be completely transparent for the enduser.

OptiPNG

This project is based on PNGCrush. According to the author, it's running faster because all trials are performed in memory. It also includes parts of PNGRewrite code for some images reductions. OptiPNG is used by a lot of optimizers, including onlines services as SmushIt.

jpegtran (libjpeg-turbo)

libjpeg-turbo is a derivative of libjpeg that uses SIMD instructions (MMX, SSE2, NEON) to accelerate baseline JPEG compression and decompression on x86, x86-64, and ARM systems. On such systems, libjpeg-turbo is generally 2-4x as fast as the unmodified version of libjpeg, all else being equal.

grunt-contrib-minhtml

Not sure if it's useful enough to be included in grunt-contrib, but might be useful. Thoughts?

https://github.com/yeoman/yeoman/blob/master/cli/tasks/html.js https://github.com/kangax/html-minifier

Prior art: https://github.com/jney/grunt-htmlcompressor But requires Java.

grunt-contrib-livereload

Yeomans livereload task is to specialized to be used, but I was just wondering if this is something that could be useful to have in contrib?

Prior art: https://github.com/webxl/grunt-reload

@sindresorhus
Copy link
Author

Assuming he does, I'll get the repos scaffolded for you right away.

Yay.

I'd go the contrib route. It is a bit more overhead to develop but I've found it to be a big win from a flexibility and community contribution standpoint.

They are super-specific tasks for a reason, trust me if I see a way to make them generic enough to be published, I surely will :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment