DEV Community

Cover image for Let’s Be Honest… Slow Websites Scare People Away 😢
Mai Chi Bao
Mai Chi Bao

Posted on

Let’s Be Honest… Slow Websites Scare People Away 😢

I'm not a professional web developer — but even so, just by following these 5 simple steps, I managed to hit 95 on PageSpeed 🚀

But hey — don’t just skim this. The last tip could make or break all your efforts.

Stick around until the end for the real game-changer!

📚 Table of Contents

🔍 Analyze with PageSpeed

Start with the easiest step — use PageSpeed Insights to check your site’s performance.

Here’s the result I got for my website mrzaizai2k.xyz:

PageSpeed Score

It not only gives you a score — it shows you exactly what’s slowing your site down:

Diagnostics

Step 1: Done — you now know where your site stands and what to fix!


✂️ Code Splitting and Reducing Unused Stuff

JavaScript can be a performance killer if not handled properly.

By default, browsers download and parse all JS — even if parts aren’t needed right away.

That’s why we:

  • Split code using tools like Webpack or dynamic imports.
  • Remove unused code, especially third-party scripts or unused CSS classes.

This reduces the size of initial payloads, speeds up rendering, and improves the Time to Interactive metric ⚡

💡 Imagine JS as a buffet — don’t serve the whole menu if the user only asked for a sandwich.


🖼️ Optimize Images

Use tools like TinyPNG to compress your images — no quality loss, just smaller size!

I optimized this image and saved 68% in size with just a few clicks:

Optimized Example

📸 Also:

  • Crop unnecessary parts.
  • Use WebP or AVIF formats when possible.
  • Set correct image dimensions to avoid layout shifts.

🔬 Code Review and Lazy Loading

Here’s how I use React.lazy() and Suspense to load components only when they’re needed:

<Suspense fallback={<div>Loading...</div>}>
  <Home2 />
</Suspense>

<img
  src={homeLogo}
  alt="home pic"
  className="img-fluid"
  style={{ maxHeight: "450px" }}
  loading="lazy"
/>
Enter fullscreen mode Exit fullscreen mode

Why this works:

  • React.lazy: breaks your app into smaller chunks. This means non-critical parts don’t load until needed.
  • loading="lazy" on images: tells the browser not to load off-screen images until the user scrolls to them.

This greatly reduces initial load time, especially for users on low-end devices or slow networks 🌍


🎨 CSS Optimizations

I keep my CSS minimal, responsive, and optimized for rendering.
Here’s one example from my code:

  .tech-icons {
    font-size: 4.5em;
    margin: 15px;
    padding: 10px;
    box-shadow: 4px 5px 4px 3px rgba(89, 4, 168, 0.137);
    transition: all 0.4s ease;
  }
Enter fullscreen mode Exit fullscreen mode

What’s going on here:

  • 🧽 Clean layout: Simple margin/padding, avoiding deep nesting.
  • 🧠 Efficient rendering: transition, box-shadow, and no heavy animations.
  • 📱 Responsive by default: Paired with media queries to scale well on mobile.

Avoid bloated libraries and unnecessary CSS classes. Stick to what you use — nothing more.


🌐 Real World Network Testing

Your site might be fast for you, but what about users on 3G or rural networks?

I tested my Projects page:
🔗 mrzaizai2k.xyz/project

Looked fine on fast Wi-Fi:
Normal Load

But in Edge DevTools, I:

  • Pressed F12
  • Opened the Network tab
  • Enabled Disable Cache
  • Switched to Slow 3G

What happened?

  1. YouTube previews didn’t load.
  2. No visual feedback = bad UX.
  3. User probably leaves before seeing your work.

My Fix:

I added a "Demo" button as a fallback, so users can still explore projects even if previews fail to load 🔁

Always think like a user:

"If I saw a blank screen, would I wait? Probably not."


🎁 What's Next

🎯 Here’s the big one:
Even with all the above, it’s not enough without thinking about build and deployment.

In the next post, I’ll show you:

  • How to create a super-light Dockerfile
  • How npm run build makes your app production-ready
  • Why deploying static files the right way boosts speed like crazy

👉 Don’t miss it — follow me so you get notified when it’s live!
👍 If this post helped you, please like, comment, or share
⭐️ A star on the repo also means a lot!


📎 References


Top comments (2)

Collapse
 
mrzaizai2k profile image
Mai Chi Bao

🛠️ So many people overlook the "real-world network" testing — that 3G trick is gold. Gotta test like your user’s still on dial-up 😂

Some comments may only be visible to logged-in visitors. Sign in to view all comments.