Chapter 31. Measure Twice, Cut Once

Tom Hughes-Croucher

There is a famous saying in English, “Measure twice, cut once” which is especially important if you do anything with your hands. Once you’ve cut a piece of wood with a saw and you find you are 5mm too short, it’s pretty hard to fix it. While software is hard to waste in the same way you can waste a raw material like wood, you can certainly waste your time.

A resource like this book is a really great tool for finding ideas to apply to your own work. Many of the authors of this book are lucky in that they spend a significant amount of their time optimizing large sites for companies like Facebook, Yahoo!, and Google (and yours truly, Walmart and others). However most developers have lots of other responsibilities other than just performance.

When you have lots of things on your plate, measuring more than pays its way. While it is easy to grab a technique that someone has laid out for you and apply it (and you should), it is also important to make sure you target the issues that affect your site the most. I was at a conference a few years ago about JavaScript and an extremely prominent, talented, and altogether smart JavaScript expert gave a talk about performance optimization. He gave a number of in-depth tips including unrolling loops and other micro-optimizations.

Here is the thing: when you are the author of a framework used by many thousands of sites every hour you spend optimizing the code pays off on every one of those sites. ...

Get Web Performance Daybook Volume 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.