Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this presentation? Why not share!

Human-powered Javascript Compression for Fun and Gummy Bears

on

  • 1,642 views

 

Statistics

Views

Total Views
1,642
Views on SlideShare
1,405
Embed Views
237

Actions

Likes
1
Downloads
4
Comments
0

7 Embeds 237

http://ruidlopes.posterous.com 214
http://rlopes.blogspot.com 12
http://www.linkedin.com 4
http://rlopes.blogspot.de 3
https://www.linkedin.com 2
http://rlopes.blogspot.ch 1
http://rlopes.blogspot.fr 1
More...

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Human-powered Javascript Compression for Fun and Gummy Bears Human-powered Javascript Compression for Fun and Gummy Bears Presentation Transcript

  • Human-powered Javascript Compression for Fun and Gummy Bears #codebits2010 :: @ruidlopes :: ruidlopes.com
  • First of all... Let there be gummy bears!
  • Javascript
  • Javascript
  • BAD!!
  • Being evil is fun!!
  • Let the fun begin
  • var context = document.getElementById('c').getContext('2d'); var dataArray = context.getImageData(0,0,200,200); var tick = function() { for (var i = 0; i < 160000; i += 4) { var color = Math.floor(Math.random() * 255); dataArray.data[i] = color; dataArray.data[i+1] = color; dataArray.data[i+2] = color; dataArray.data[i+3] = 255; } context.putImageData(dataArray, 0, 0); }; window.setInterval(tick, 1);
  • 405 331 255 Original Google Closure Google Closure (agressive)
  • 37% decrease (not bad – for a robot)
  • Javascript
  • shorter variable names 333
  • ‘window’ is... redundant 326
  • only one function 314
  • DOM is versatile 311
  • assignments return values 301
  • DOM is freaking versatile! 277
  • Know your APIs inside out 217
  • pure evil variable creation 215
  • know your loops 199
  • master your automatic type-casting 187
  • numbers have different representations 181
  • ok, let’s remove some whitespace now 153
  • know your math 152
  • “function” is expensive, just eval it. 139 already fits a twit!
  • ; is optional, sometimes 135
  • Humans Robots 500 375 250 125 0
  • 67% decrease (pretty awesome – for a human)
  • get inspired by raphaël.js js1k the incredible demoscene
  • Thank you!