DEV Community

Cover image for Lazy Loading: Do you really know what it is?
Sunil Chaudhary
Sunil Chaudhary

Posted on

Lazy Loading: Do you really know what it is?

Introduction: Not Your Usual Lazy Loading Blog

If the title intrigued you and you’re expecting a straight answer; this isn’t that blog. But... if you’re here to think, explore, and maybe chuckle a bit, you’re in the right place. 😝

If you ask a developer (or check MDN), you’ll get something like this:

Lazy loading is a strategy to identify resources as non-blocking (non-critical) and load these only when needed. It's a way to shorten the length of the critical rendering path, which translates into reduced page load times.

Here is my tongue-in-cheek definition 😝:

Lazy loading is a strategy developed by SPA libraries owners to clean the mess created by SPA libraries owners when they thought moving from simple server rendered single pages to heavy client side bundled pages is a good idea.

A Short History of Web Rendering

Decade(s) ago, a lot of pages and content were server rendered with only the css, js etc related to that page getting downloaded ('MPA' or 'Multi Page Application').

Then came SPA.
Why? Some people thought it will make applications and subsequent page loads faster, interactions will be better (which are). But no one thought about the initial load time? or the increasing TTI with large bundle sizes? Here comes Lazy loading to the rescue. (Create a problem, then fix it yourself and get kudos from the community on problem which shouldn't have existed in the first place 🤣🤣)

Then comes Code splitting; then comes Lazy Loading; then comes SSR frameworks like NextJs, RedwoodJS; and now we are going back again to MPA style Frameworks from where we started in the first place. With shinier tooling.

Moore’s Law question

What do you think? Are apps genuinely faster today because of these strategies, or is Moore’s Law doing most of the heavy lifting?

Of course there are improvements! People will argue that things are faster. But Are applications really faster due to this? I will probably write another blog on this. Try running the current application in a system that’s decades old. And one will realize that improved hardware, RAM, CPU, GPU etc might be playing a more important reason for better performance than these.

The Cycle Comes Full Circle

  • Isn't it funny, the entire cycle is completed! Evolution of Web Applications - A funny take
  • It is also funny that in grand scheme of life, almost every time "History Repeats Itself" or each generation tries to improve a situation only to land back in same situation and never to realize it. In this case:
    • We started with server-rendered MPAs.
    • We moved to client-rendered SPAs.
    • We added lazy loading to fix SPA problems.
    • SSR and SSGs coming into place.
    • Now frameworks are pulling us back to MPA-style rendering. And here we are, celebrating the “new” solution that looks suspiciously like the old one. Almost like... history repeating itself.

Maybe lazy loading is brilliant. Maybe it’s a band-aid.
Or maybe it’s just proof that in tech, as in life:

We love solving problems we created ourselves.

Thoughts?

(Truly speaking, this is just a thought process right now; will dig much deeper into it;)

Top comments (0)