You Can Read the Source

Level Up!
By
Published ~ 3 minutes read

Internet speed keeps getting faster every year, and today's mobile devices often outperform older desktops. But just a few years ago, catering to mobile users was a delicate art. If you wanted to offer a smooth experience, you had to minimize the number and size of JavaScript files. A large file could freeze or even crash a mobile device. Desktop users on older browsers like Internet Explorer faced similar challenges.

To address this, many websites adopted the "lighter version" approach, redirecting low-performing devices to subdomains like m.example.com. Here, every single line of code was scrutinized for efficiency. You couldn't casually throw in a 2MB JavaScript file; you had to ensure every script was optimized and did only what was absolutely necessary.

This environment forced developers like my team and me to deeply understand the libraries we included. We weren't just blindly copying and pasting code; we read through the source to figure out exactly how it worked so we could replicate only the functionality we needed.

For one project, I was tasked with removing jQuery. At the time, jQuery wasn't considered large by modern standards, but it was the heaviest script on our page. While jQuery made programming accessible by smoothing over browser quirks, it was possible to replace many of its features with native code. We swapped $() with document.getElementBy* and replaced utility functions one by one. The trickiest part was detecting when the DOM was ready, a process that wasn't standardized across browsers back then. Reading through jQuery's source code taught me how it handled these quirks, and with that knowledge, we could implement a lightweight alternative.

This experience gave me a newfound appreciation for the underlying mechanics of the browser. jQuery was powerful, but we rarely needed everything it offered. Similarly, we replaced moment.js, another popular library at the time, with just a single line of code because our use case was so specific. By analyzing what we actually needed and reading the source, we saved time, bandwidth, and headaches.

This habit of reading source code extended beyond libraries to frameworks. I dove into Symfony and Ruby on Rails, both of which are beautifully structured and packed with lessons for anyone willing to explore. I even looked at a tiny framework called Hyperapp. Its simplicity was eye-opening, and I learned how to extract just the pieces I needed for my own projects.

More recently, I've been exploring React. Despite using it for years, its structure still feels unintuitive to me. However, digging into its source code has provided insights that even the documentation can't teach. The patterns and trade-offs the React team made reveal valuable lessons about building scalable, efficient tools.

Reading the source isn't just about removing dependencies or slimming down your codebase; it's about leveling up as a developer. When you take the time to understand how a library or framework works under the hood, you gain a deeper knowledge of the tools you're using and the problems they're solving. That knowledge, in turn, helps you write better, more efficient code.


Did you like this article? You can buy me a coffee.
Share your insightful comments here.

Join my newsletter

Follow me on Twitter, Spotify, or RSS Feed

On a related note, here are some interesting articles.

Solving problems

In high school I always wondered how some kids memorized all the math formulas. Especially the long ones. I am not particularly good in math but since I am terrified with the idea of giving up I kept at it until I found ways to deal with it. I couldn't memorize the formulas but knowing the first few digits of a sine and cosine of special angles (30,45,60 and so on) proved to be very useful. I loved computers since I was a kid and I was labeled the computer guy in the family. Everyone came to me (and still do) to get help with the Microsoft Word issues, Excel, modem setup, unresponsive mouse, broken screen (not that I could do much with a broken CRT monitor), driver update, unplugged cable, and so on. I may be very disorganized but one thing I can say for sure is I almost aways find a solution to the problems presented to me.

Language is culture not just syntax

I am lucky to have been exposed to many languages as a child. I lived in a city where almost everybody was from a different country. On the average day I would hear at least 4 languages being spoken. French and Fulani at home, English on TV, Arabic on the street and various other languages ranging from Bengali to Swahili from my peers. If you are at least bi-lingual then you know how jokes lose all their substance when translated. A language is more than just being grammatically correct. Words that make up a language not only come with connotation but there is a culture associated with it. With all the baggage it carries, the language makes you think in a certain way. Programming languages do not escape this rule. Each programming lingo comes with it's own set of rules, syntax, and culture.

I love your work, send me your resume

Every so often I get an email from a CEO, CTO, or someone running the show in a company. They see my blog, go through my stackoverflow, check some of my projects and they feel it is only natural to contact me. I am currently employed, but I am always open for the right offer.

View all articles

Comments

There are no comments added yet.

Let's hear your thoughts

For my eyes only