How we reduced Next.js page size by 3.5x and achieved a 98 Lighthouse score

Paragraph

How we reduced Next.js page size by 3.5x and achieved a 98 Lighthouse score

How we reduced Next.js page size by 3.5x and achieved a 98 Lighthouse score

Colin Armstrong

<1 min read·December 3, 2021
nextjs
react
programmingtips

Collect this post as an NFT.

Paragraph

Subscribe to Paragraph to receive new posts directly to your inbox.

Farcaster
timdaub
Commented 2 years ago

Kiwi News bundle.js. It's sadly 2MB big and I'd like to reduce its size. But I don't see any obvious optimizations.

Farcaster
Colin
Commented 2 years ago

are you lazy loading? eg loading connectkit lazily when needed since it's massive

Farcaster
timdaub
Commented 2 years ago

I switched to script defer now

Farcaster
timdaub
Commented 2 years ago

@colin but I don‘t do code splitting, should I? It seems like massive complexity increase

Farcaster
:grin:
Commented 2 years ago

just delete it all. that site doesn't need any js

Farcaster
timdaub
Commented 2 years ago

actually web3 without JS is sadly not possible but otherwise I‘d do it

Farcaster
Phil Cockfield
Commented 2 years ago

I'm playing a similar code-splitting game with "@farcaster/hub-web" right now! I feel 'ya @timdaub.eth !!! Bundle size explosion can be like playing whack-a-mole. I find knocking it in the head early is the easiest way as untangling later become disproportionately harder and harder for me to get my head around.

Farcaster
timdaub
Commented 2 years ago

😞

Farcaster
Phil Cockfield
Commented 2 years ago

I'm sneaking up on it! Haven't put any real work into busting that "blood clot" up yet. Good luck with your bundle surgery! 🫠💪

Farcaster
pugson
Commented 2 years ago

https://www.framer.com/motion/guide-reduce-bundle-size/

Farcaster
timdaub
Commented 2 years ago

npm ls framer-motion web@0.0.0 /Users/timdaub/Projects/attestate/kiwistand/src/web └─┬ connectkit@1.2.4 └── framer-motion@6.5.1 hehe

Farcaster
timdaub
Commented 2 years ago

@pugson more work: https://github.com/family/connectkit/issues/231

Farcaster
Matthew
Commented 2 years ago

Are you using Next 13? that’s one alternative idea also wonder what rainbowkit size v connectkit would be

Farcaster
timdaub
Commented 2 years ago

nope, express and reactjs

Farcaster
notdevin
Commented 2 years ago

I’m kinda digging the way next splits up client and server code, I’ve been trying to go deep on the next app directory designs

Farcaster
Joe Toledano
Commented 2 years ago

Can you migrate from Ethers to Viem?

Farcaster
timdaub
Commented 2 years ago

I‘m open to it but what are the consequences and what do I gain?

Farcaster
Joe Toledano
Commented 2 years ago

Outside of the time to migrate, would check to see if there's any gaps in coverage for how you currently use Ethers (migration guide: https://viem.sh/docs/ethers-migration.html) but you'd likely see some benefits from a bundle size & performance standpoint: https://viem.sh/docs/introduction.html#bundle-size

Farcaster
Charles Yoo-Naut
Commented 2 years ago

Are multiple dependencies loading different versions of BigNumber? This was something that was bothering me but couldn't figure out a good solution

NFT Image

Over 3.1k subscribers