PerformanceJS

a blog by Boris Cherny

Introducing: Lazy arrays in JavaScript

Today I’m introducing lazy-arr, which brings lazy arrays to JavaScript.

What’s a lazy array and why is it useful?

Flashback to your job interview for your first software engineering job: let’s write a Fibonacci function. We define the base cases of 0 and 1, then recurse to generate the rest:

Read more...

Automatically generating base64 inline images with SASS

Base64 encoding has been around for years, and when applied to images (among other data) in the form of Data URI’s, is a crucial tool in the performance geek’s arsenal.

Why Base64?

While base64 encoding increases the byte size of encoded content by around 1/3[1], it has the potential to dramatically cut down on HTTP requests and latency per resource. Since many browsers allow only a few connections per host (iOS allows 4-6, IE8/9 allows 6, and IE6/7 allows just 2, as per the HTTP 1.1 Spec), inline images are often a good alternative to many small external images, which would be forced to be fetched in sequence rather than pipelined. For relatively small media inlined in CSS, another benefit comes in the form of no more flash of unstyled content: inline images will load at the same time as the containing CSS file.

Read more...