This contains some lessons I learned the hard way by maintaining a media-rich Next.js blog on Vercel for several years.
Initially, my focus was keeping the editing interface clean and fast: I like to work directly in MDX and I started out including images directly in my codebase. Over time, as I continued blogging, building demos and adding images and demo gifs to my site, build times started to climb.
Eventually I reached a point where my build was 5 minutes. I rolled up my sleeves and refactored my entire application:
- Changing up static → ISR pages wherever possible
- Migrating all images to Bunny CDN and replacing all references across my site
- Optimizing my custom OpenGraph image integration to improve its efficiency.
Overall, I was able to drop my build times 66% - and I’m keen to get them down even lower. But 1 minute and 52 seconds is night and day from 5.5 minutes…