- ✓A Next.js 14 or React web project
- ✓Basic familiarity with Chrome DevTools Performance and Network tabs
🚀 What You Will Learn & Build
- ▸Reduce bundle size by 60%+ using modern image formats and responsive picture sizing
- ▸Eliminate Flash of Unstyled Text (FOUT) on slow mobile connections using font subsets
- ▸Prevent layout shifts caused by dynamic banners and unreserved media slots
- ▸Achieve 95+ mobile Lighthouse scores on real NTC and Ncell mobile networks
1. The Reality of Mobile Performance in Nepal
2. Crushing Largest Contentful Paint (LCP < 2.5s)
/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
formats: ['image/avif', 'image/webp'],
deviceSizes: [640, 750, 828, 1080, 1200, 1920],
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
minimumCacheTTL: 60 * 60 * 24 * 30, // 30 days cache for CDN edge
},
};
module.exports = nextConfig;3. Devanagari & Latin Font Subsetting (next/font)
import { Inter, Mukta } from "next/font/google";
// Latin typography for code and English headings
export const inter = Inter({
subsets: ["latin"],
display: "swap",
variable: "--font-inter",
});
// Devanagari typography for Nepali text
export const mukta = Mukta({
weight: ["400", "600", "700"],
subsets: ["devanagari", "latin"],
display: "swap",
variable: "--font-mukta",
});✨ Expected Output & Verification
A high-performing Next.js application that achieves green Core Web Vitals across LCP, INP, and CLS on throttled mobile connections.
🧪 How to Test the Implementation
- 1Configure Slow 4G network throttling in Chrome DevTools Network tab
- 2Audit homepage using PageSpeed Insights and verify LCP < 2.5s
- 3Verify next/font subsetting delivers zero Flash of Invisible Text
- 4Check Cloudflare Edge cache headers (CF-Cache-Status: HIT)
⚠️ Common Errors & How to Fix Them
Root Cause: Uploading raw DSLR camera photos directly into the /public folder.
Fix: Resize hero photos to a maximum width of 1920px and compress using Squoosh.app or Sharp CLI before committing to Git.
Root Cause: Custom fonts without display: 'swap' causing FOIT (Flash of Invisible Text).
Fix: Specify display: 'swap' in your font declaration so a fallback system font is displayed instantly until custom glyphs download.
🛡️ Security Considerations & Best Practices
- !Ensure third-party script sources are explicitly whitelisted in your Content Security Policy (CSP) headers.
❓ Frequently Asked Questions (FAQ)
Yes! Cloudflare has Edge Points of Presence (PoPs) in Kathmandu (KTM) peering directly with major Nepali ISPs like WorldLink and NTC, reducing asset latency from 150ms+ to under 15ms.
📌 Summary of Key Takeaways
Optimizing Core Web Vitals for Nepal means prioritizing mobile 4G latency with Next.js priority hero images, AVIF/WebP compression, font subsetting, and lazy-loading third-party analytics.
Official References & Further Reading
Written by Manoj Neupane
AuthorSoftware developer and programming instructor, Nepal
Building software systems and SaaS platforms with Laravel, Next.js, and Node.js. Passionate about helping students and developers in Nepal master practical, real-world development skills.