2015.01.09

is Promise.prototype.then the fastest “nextTick”?

I spent the past week optimizing the startup performance of a Firefox OS web app. While analyzing the profile and timeline data I realized that the DOMEvent “message” was causing a considerable delay – That “message” is actually based on David Baron’s setZeroTimeout function, which is used a few times along the codebase; So I had the idea to use a resolved Promise and check if it was going to change anything and I was impressed with the performance gains! So I decided to search if anyone else got into the same results, but couldn’t find anything and decided to write this post.

Read more…


2013.05.15

Linked Lists for Dummies

On high-level languages like JavaScript we usually don’t care about how the objects are stored in the memory, we let the VM handle it for us, and since the language contains Arrays most users never find a need for Linked Lists even tho it’s a very powerful and useful data structure.

Like most front-end developers I don’t have a Computer Science degree and started to program using high level languages, it took me a while to stumble into Linked Lists, that’s why I’m going to explain the basic use cases, pros/cons of this simple data-structure and why it’s widely used. - You probably used it before without knowing.

This post was motived by this tweet:

Read more…


2011.09.10

Benchmarking is hard

I’ve seen a lot of people creating benchmarks that are misleading and sometimes I even create some “biased” benchmarks myself. On this post I will try to explain how measuring things the wrong way can make you believe that a certain technique is faster but in real-life applications it may have the opposite effect or not so significant gains.
Read more…


2010.12.08

Using integers to store multiple boolean values

Before starting I have to say that I come from a design background and not so long ago I didn’t know anything about bitwise operations, in fact I didn’t even know that it existed, the content described on this post should be trivial for developers coming from a computer science background or low-level languages…

The intention of this post is not to teach what each bitwise operator does, in fact I’m going to explain how to use it without telling what it does since I think it may be easier to understand. The main reason for writing this post is because I had to explain this technique to a couple of different friends over the past years (or at least I tried…) and also because I believe that most front-end developers don’t know about it.

I think I’ve learned it around 3 years ago when I was planing to code a multiplayer RPG game with a couple of friends and was doing some research about ways to optimize data transfer, that was probably the first time I saw a real use for bitwise operations on high-level programing besides splitting color channels…
Read more…


2010.10.04

The performance dogma

On the past couple years I’ve been noticing that the web community (specially front-end devs) started to become more interested and to care way more about performance, trying to make applications load and execute as fast as possible. I think it was mostly influenced by Steve Souders High Performance Website and Yahoo’s Performance Rules.

Performance is a very important topic, which can directly influence the success/fail of an application, but I do believe that some people are getting things wrong and exaggerating a little bit (including myself)… – Of course everybody wants their applications to run and load as fast as possible but “optimizing” things without need is simply wrong. A common quote about performance explain this:

We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%. A good programmer will not be lulled into complacency by such reasoning, he will be wise to look carefully at the critical code; but only after that code has been identified” – Donald Knuth

Read more…