Badass JavaScript

A showcase of awesome JavaScript that pushes the boundaries of what's possible on the web, by @devongovett.

140bytes: A Community Curated Collection of Tweet Sized JS

November 1st 2011

Last May, Jed Schmidt started a fun little game of “code golfing" on Github’s Gist feature called 140bytes, in which people competed to write Tweet-sized JavaScript to accomplish specific tasks.  Since then, hundreds of little scripts of varying complexity have been collected, a website and Twitter account have been created to collate these scripts, and a very nice page listing lots of byte-saving techniques has been written.

The scripts themselves range from polyfills to sudoku solvers to useful color conversion utilities.  Here are some of my favorites (in no particular order):

  1. A Sudoku solver
  2. A Base64 Encoder
  3. HSL to RGB color converter
  4. HEX to RGB color converter
  5. RGB to HEX color converter
  6. HSV to RGB color converter
  7. A micro templating engine
  8. A UTF8 Encoder
  9. A Twitter @mention/#hashtag auto linker
  10. A UUUD generator
  11. A Google Analytics snippet in 140 bytes
  12. A credit card validator
  13. An LZW compressor
  14. A latitude-longitude distance calculator
  15. Music Soft Synth - a WAV synthesizer in 140 bytes

So as you can see, it is possible to do many impressive things in a very short amount of code.  Next time you are in need of a short little snippet, check if there is a 140 bytes entry for what you are looking for.  Please be careful, however, as sometimes browser support and functionality are sacrificed in order to reach the 140 byte limit.

If you’re interested in playing yourself, all you have to do is fork the master gist, edit according to the rules in the gist, save your entry and tweet it to @140bytes to let them know.

Have fun!