Grant Application: swap.cow.fi performance - bundle optimization
Senior Web Developer - Konstantin Barabanov: (https://github.com/crutch12) Main Point of Contact - https://t.me/criitch
Currently, the swap app build command generates following js bundle:
My tests have showed that we can reduce these sizes to:
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:
@1inch/permit-signed-approvals-utils version and use via async import@cowprotocol/permit-utils breaking change (getPermitUtilsInstance is async now), so we have to release it with new major version@safe-global version and use @safe-global/api-kit via async import@safe-global don't require protocol-kit and safe-ethers-lib usageweb3 requirementsbn.js@walletconnectframer-motion via async importlottie-react via async importlottie/progressbar-step-*.json via async importmanualChunks usageAlso: many deps have new releases with esm support, so we win a huge amount of size thx to tree shaking.
Expected impact:
Another changes/features I would like to provide with this feature
Milestones-based
| 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 |
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.
800 xDAI + 1000 COW for the whole feature.
0xd26ecc4457eb51cde9a5d44d316b3e83d60f2efb
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:
web3-react depsswap) via react's lazy@ethersproject to viem@uniswap via async importcommon and modules modules via async import (they are really huge!)@safe-global via async import@defuse-protocol/one-click-sdk-typescript via async importBy submitting this grant application, I acknowledge and agree to be bound by the CoW DAO Participation Agreement and the CoW DAO Grant Agreement Terms.