Sabbatical dev

sabbatical devtechnical blog
 

Reducing your bundle size

I found this tool helpful

Recently I have been preparing my new Next.js application for production on vercel

Its quite a feature rich solution (more details coming once I go live), but I decided that I would try and use Vercel's serverless functions.

As I am in the very beginning phases of my app, I wanted to keep my budget as low as possible, but I wanted the application to be able to scale in all ways.

Vercel's serverless functions are build on AWS Lambda, but on a hobby plan you have some tighter restrictions, read here for more info on these.

Once I was running in Vercel, I started hitting the timeout exception, and began the work of optimisation.

I found this article Scott Anderson very helpful, it talked about reducing my bundle size, caching and Performance of the code in getServerSideProps().

When trying to reduce my code I came across the Import Cost VSCode plugin.

I really like this simple little plugin, It simply comments the size of the imported library uncompressed and gzipped size.

Its a small thing but its really helpful and its made me think allot more about the packages I choose to import,

whether I need them or if there is a better alternative available. I'd recommend this anyone, but especially those like myself who need to keep that bundle cost low.


Comments

Add a comment