Grant Title
Grant Application: swap.cow.fi performance - prerender html
Author(s)
Senior UI Developer - Konstantin Barabanov: ( crutch12 (Konstantin Barabanov) · GitHub )
Main Point of Contact - Telegram: Contact @criitch
Experiences and qualifications
- 8+ years of web development experience (one year with web3 projects)
- have a lot of experience with react/vue apps optimization, SSR and MF usage
- already did some contributions to swap.cow.fi repo (see issues)
- more info about me is available here (rus.) and on github
Grant Description
Currently, the swap app renders most content at runtime, which may lead to slower first paint and FOUC (flash of unstyled content). By prerendering the main elements, users can experience faster loads.
I want to implement partial prerendering for the swap app’s index.html at build time, similar to SSR/SSG. The goal is to render the <Main> component (without routes) along with app’s styled <style> tags, improving initial load performance and enabling better theming support.
These changes will affect output index.html file, but won’t require SSR server. So this approach is similar to SSG, but since we use <HashRouter>, we don’t want to prerender routes (pages), only “main layout”.
Features/tasks:
- Prerender
index.htmlat build time - Keep same build time and bundle size (no
server.entry.jsrequired) - Mock any required browser api during prerender
- Render
<Main>component without route-specific content - Include styled
<style>tags for non-page components - Optimize theme usage for dark/light modes, so user could see correct styles immediately
- Provide empty i18n messages during prerender (e.g. whitespace placeholders)
- Provide prefetched i18n messages during client render (currently,
i18n Providerrerenders the whole application after messages fetching, so we have extra rerender) - No hydration needed, just recreate
#rootdom node when client is ready (make sure there is no manual manipulation with#root)
Expected impact:
- Faster first paint and perceived performance
- Improved user experience with instant styled content
- Better foundation for future SSR-like features
We don’t need SSR server, thus it’s still possible to host it with IPFS.
Type of Grant
Milestones-based
Milestones
| Milestones | Title | Duration | Funding request |
|---|---|---|---|
| Milestone 0 | Proof of Concept (PoC), prepare PageSpeed Insights reports | COMPLETED | 500 xDAI |
| Milestone 1 | Mock any required browser API during prerender | 0.5d | 0 |
| Milestone 2 | Setup vite config for prerendering | 1d | 0 |
| Milestone 3 | Adapt components to be used in ssr-like mode (and skip unwanted) | 1d | 0 |
| Milestone 4 | Render client application with prefetched i18n messages | 0.5d | 0 |
| Milestone 5 | Provide i18n messages during prerender | 0.5d | 0 |
| Milestone 6 | UI light/dark theme adaption for prerendered components | 1d | 0 |
| Milestone 7 | Adapt another ui apps to use modified libs components | 1d | 0 |
| Milestone 8 | Testing | 1d | 0 |
| Milestone 9 | Update contribution docs | 0.1d | 0 |
| Milestone 10 | Provide PR | 0d | 800 xDAI |
| Milestone 11 | Fix found related problems | unknown | 0 |
Length
I’m ready to start as soon as the grant is approved. I’m not gonna work full time on it, but believe I can complete it in ~2 weeks after approve.
Funding Request
1,300 xDAI for the whole feature.
Gnosis Chain Address
0xd26ecc4457eb51cde9a5d44d316b3e83d60f2efb
Other Information
I’ve already did a prototype (PoC) 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 multiple times lower with partial prerendering feature.
I don’t host prototype anywhere, but can share temporal link with anyone on demand.
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.

