#ASKTHEINDUSTRY 07: Why the “one less JPG” mantra is all wrong today?
In today’s web development industry there is one recurring theme that almost everyone is getting wrong:
“Let’s drop in this 100kb JS library to implement that feature. Just ship one less JPG and we’re set.”
I’ll give you the punchline first: in today’s Web, this mantra is all wrong. Why? I’m glad you asked. The reason is pretty straightforward: your JavaScript library is not just adding its file weight, it also adds the cost of both parsing and then evaluating the code.
This means that 100kb of JavaScript are >>> (way bigger) than a 100kb JPG image. This is especially relevant if you think about this one fact: in October 2016, the web traffic coming from mobile devices surpassed for the first time desktop traffic. Such an event changes the landscape, we cannot ignore anymore the fact that mobile devices are so less powerful and so much more interested in saving power than your typical machine. Take a look at this slide from the Chrome Dev Summit:
As it turns out, on a Nexus 5, 1MB of ungizipped JS takes up to 2 full seconds just in the parsing phase!
It can’t be stressed enough, it’s not just about the file weight. It really isn’t.
This piece is part of the #ASKTHEINDUSTRY project, a series of daily conversations with the Web Dev industry. You ask, I’ll answer, or find someone who can.