Grant Application: swap.cow.fi performance - bundle optimization

Grant Title

Grant Application: swap.cow.fi performance - bundle optimization

Author(s)

Senior Web Developer - Konstantin Barabanov: (crutch12 (Konstantin Barabanov) · GitHub)
Main Point of Contact - Telegram: Contact @criitch

Experiences and qualifications

Grant Description

Currently, the swap app build command generates next js bundle:

  • Total size: 19.02 mB (4.52 mB brotli)
  • Initial js load size: 7.8 mB (2.16 mB brotli)

My tests have showed that we can reduce these sizes to:

  • Total size: 16.63 mB (4.12 mB brotli)
  • Initial js load size: 4.41 mB (1.32 mB brotli)

So the initial load boosts up more than x1.5 times.

And it can be achieved just using some bundle optimization techniques: without significant code base changes and without a lot of effort.

Here is the list of applied optimizations:

  • update @1inch/permit-signed-approvals-utils version and use via async import
    • this library is archived, so we may copy some implementation to get rid of the most often usages
    • this update leads to @cowprotocol/permit-utils breaking change (getPermitUtilsInstance is async now), so we have to release it with new major version
  • update @safe-global version and use @safe-global/api-kit via async import
    • new versions of @safe-global don’t require protocol-kit and safe-ethers-lib usage
    • no more web3 requirements
    • update changes return types a little, so had to fix it
  • deduplicate bn.js
  • update @walletconnect
  • use framer-motion via async import
  • use lottie-react via async import
  • use lottie/progressbar-step-*.json via async import
  • better vite’s manualChunks usage

Also: many deps have new releases with esm support, so we win a huge amount of size thx to tree shaking.

Expected impact:

  • Faster first paint and perceived performance (> x1.5 times). See the pagespeed metrics comparison in the first comment.

Another changes/features I would like to provide with this feature

Type of Grant

Milestones-based

Milestones

Milestones Title Duration Funding request
Milestone 0 Proof of Concept (PoC), prepare PageSpeed Insights reports COMPLETED 400 xDAI + 500 COW
Milestone 1 Prepare changes for neat PR 1d 0
Milestone 3 Better naming, bundle-stats usage 0.5d 0
Milestone 4 Testing 1d 0
Milestone 5 Update contribution docs, setup eslint rules 0.5d 0
Milestone 6 Provide PR 0d 400 xDAI + 500 COW
Milestone 7 Fix found related problems unknown 0

Length

I’m ready to start as soon as the grant is approved. I won’t work full time on it, but believe I can complete it in ~1 week after approve.

Funding Request

800 xDAI + 1000 COW for the whole feature.

Gnosis Chain Address

0xd26ecc4457eb51cde9a5d44d316b3e83d60f2efb

Other Information

I’ve already did a prototype and will provide PageSpeed Insights reports in the first comment.

As you can see, such metrics as First Contentful Paint, Speed Index, Largest Contentful Paint are lower with those optimizations.

Future (out of current scope) steps could be:

  • get rid of web3-react deps
  • load every page (except swap) via react’s lazy
  • migrate @ethersproject to viem
  • use @uniswap via async import
  • use some common and modules modules via async import (they are really huge!)
  • in cow sdk libs: use @safe-global via async import
  • in cow sdk libs: use @defuse-protocol/one-click-sdk-typescript via async import

Terms and Conditions

By submitting this grant application, I acknowledge and agree to be bound by the CoW DAO Participation Agreement and the CoW DAO Grant Agreement Terms.

PageSpeed Insights

PageSpeed Insights reports, made in same conditions with temporal web servers

Without bundle optimizations

With bundle optimizations


analyse.html comparison

And here are analyse.html files, available on vercel deployments:

Initial js load size comparison


Hi, thanks for your grant application, however after discussion with the Grants Committee, we signal that we are not interested in pursuing this grant application.

Got it.

Thanks for quick response!

Hi @crutch12 !
Thanks for the application!

I think it’s quite valuable for CoW Swap, I would like to have it done.
@mfw78 can we reconsider this application please?

Thanks for reviewing this and reaching out. Sorry @crutch12 that it got caught in the cross-fire and incorrectly considered as spammy :see_no_evil_monkey: .

I signal my interest in supporting this grant given that there is now tractable evidence that it will have both benefit and be utilised by CoW Swap.

3 Likes

Snapshot: https://snapshot.box/#/s:cowgrants.eth/proposal/0x8a2b120f3e869a175e1de19b6516980b0d325bc06f41b0e32c89cb9da3ed42b5

@middleway.eth @Chim9 @Sov could you check it out, please? :folded_hands:

I’ve created the snapshot according to the rules: How to Apply for a Grant | CoW Protocol Documentation

I hope it’s not too early… If it is, I can create a new snapshot later

What I meant here:

Currently, the swap app build command generates following js bundle:

Just to clarify :face_with_peeking_eye:

Hi, can you please resubmit your grant to snapshot. Generally we advise to not submit over the weekend due to the voting period of 3 days and it failing to reach quorum there.

1 Like

Hi

Yeah, sure. I’ll know next time.

New snapshot: https://snapshot.box/#/s:cowgrants.eth/proposal/0x7095f94ee737b5d4983f744fc1c4ad58d3b8ea6f28f60814fb0a8332d603db4d

Hi @mfw78

Should I mention somebody else to check the snapshot?

@crutch12 It looks like there are enough votes in to pass, and it has met quorum. I can send more details here re: next steps for onboarding after the vote is finalized (probably 12/26 due to holidays).

1 Like

@crutch12 congrats, the CoW Grants Council has approved your grant proposal via Snapshot. We’re excited to support your work to optimize swap.cow.fi bundle to achieve >1.5x faster initial load performance.

Grant: swap.cow.fi performance - bundle optimization
Grantee: @crutch12
Amount: 800 xDAI + 1,000 COW
Approved: Snapshot on December 25, 2025


Your Grant Team

@Sov - Process, payments, and approvals
@mfw78 - Technical review and quality standards

This is a milestone-based grant with two payment points. Your approved proposal governs all details.


Milestone & Delivery

Milestone Deliverable Due Date Payment
M0 Proof of Concept, PageSpeed Insights reports Completed 400 xDAI + 500 COW
M6 Bundle optimization PR (prep, naming, testing, contribution docs, ESLint rules) January 1, 2026 400 xDAI + 500 COW

Success metric: Reduce initial JS load from 7.8 mB to 4.41 mB (brotli: 2.16 mB → 1.32 mB), achieving >1.5x faster first paint and perceived performance.

When you complete a milestone, post in this thread with links to deliverables (GitHub, docs) and tag @Sov and @mfw78

Approved milestones are included in the next end-of-month payout cycle, with funds arriving by the 15th of the following month.

Post progress updates every 2-4 weeks. Flag blockers early. Small changes can be approved directly by your team. Major changes need a Snapshot vote.


Your Responsibilities

Execute your proposal as approved and deliver on time to the quality standards you committed to. Post proactive progress updates in this thread - don’t wait for us to ask. When you hit issues, flag them early. When you complete milestones, post deliverable links and tag your team. If timelines shift, discuss in this thread.

Deliverables must be open source. You’re an independent contractor handling your own taxes. Review full grant terms here and here.


Please reply to confirm that you’ve read this onboarding, provide your Gnosis Chain payment address (which must match your Snapshot signing account), confirm that you understand your responsibilities, and acknowledge that you can reach your Steward and Reviewer via the contacts above.

Once confirmed, you’re clear to start building. Questions? Tag @Sov for process/payments or @mfw78 for technical issues. :cow_face:

1 Like

@Sov

Got it, thanks.

Address: 0xd26ecc4457eb51cde9a5d44d316b3e83d60f2efb

Start to implement described milestones :saluting_face:

Here is the most part of the feature: refactor(swap): bundle optimization by crutch12 · Pull Request #6775 · cowprotocol/cowswap · GitHub

@shoom3301 @Sov @mfw78

All that’s left are tests and possible testing problems

2 Likes