Skip to content

Conversation

@KirillKirill
Copy link
Contributor

@KirillKirill KirillKirill commented Jul 2, 2025

Issue tracking

Not ticketed

Context behind the change

This PR aimed to boost a performance of the Dashboard App. That was mostly achieved by tree shaking of our sdk module (that got us the biggest perf bump) and mui icons, and minifying the main bundle via vite and its options.
The screenshots below show, how a performance got bumped on the heaviest pages (Home and Search Results) and how was decreased the main bundle and time to build the app.
Also I eliminated a layout shift on pages and added aria labels to some buttons in order to improve the accessibility score

Screenshots

x5 less modules to transform, x2.5 less size of the main bundle, 1.5 seconds less to build the project

Before After
img img

+15 perf points and +10 a11y points

Before After
img img

1 second less to paint the first elements, no layout shift

Before After
img img
Before After
img img
Before After
img img

How has this been tested?

running yarn build, then yarn preview, then run Lighthouse in Chrome

Release plan

regular

Potential risks; What to monitor; Rollback plan

no risks i guess

@vercel
Copy link

vercel bot commented Jul 2, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
human-dashboard-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 10, 2025 1:51pm
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
faucet-frontend ⬜️ Ignored (Inspect) Visit Preview Jul 10, 2025 1:51pm
faucet-server ⬜️ Ignored (Inspect) Visit Preview Jul 10, 2025 1:51pm
human-app ⬜️ Skipped (Inspect) Jul 10, 2025 1:51pm
staking-dashboard ⬜️ Skipped (Inspect) Jul 10, 2025 1:51pm

Copy link
Collaborator

@dnechay dnechay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work!
Next improvement would be to update mui to latest version ;)

My only concern is direct import from @human-protocol/sdk/src/... of sdk, which implies knowledge about package internals. I understand that there is no option to do it in another way atm, but maybe we can prepare a separate PR for SDK where we improve that (as well as exporting some other useful types from there, such as EscrowData), wdyt @portuu3 @flopez7?

@flopez7
Copy link
Contributor

flopez7 commented Jul 2, 2025

Amazing work! Next improvement would be to update mui to latest version ;)

My only concern is direct import from @human-protocol/sdk/src/... of sdk, which implies knowledge about package internals. I understand that there is no option to do it in another way atm, but maybe we can prepare a separate PR for SDK where we improve that (as well as exporting some other useful types from there, such as EscrowData), wdyt @portuu3 @flopez7?

All this data is already exported in SDK, we can directly do import { ChainId } from '@human-protocol/sdk';
@KirillKirill @dnechay

@KirillKirill
Copy link
Contributor Author

@flopez i need to specify full path to file (e.g import { ChainId } from '@human-protocol/sdk/src/enums'), because otherwise it would pull the whole sdk, which is huge. the reason why vite pulls the whole sdk is that it can't properly tree-shake the package. now, when you import from sdk's index file, it imports all the modules, because sdk uses a barrel export pattern, which prevents proper tree-shaking

@portuu3
Copy link
Collaborator

portuu3 commented Jul 3, 2025

@flopez i need to specify full path to file (e.g import { ChainId } from '@human-protocol/sdk/src/enums'), because otherwise it would pull the whole sdk, which is huge. the reason why vite pulls the whole sdk is that it can't properly tree-shake the package. now, when you import from sdk's index file, it imports all the modules, because sdk uses a barrel export pattern, which prevents proper tree-shaking

What would be the changes to apply to fix this? @KirillKirill

@KirillKirill
Copy link
Contributor Author

KirillKirill commented Jul 3, 2025

@portuu3 i might be mistaken, but we need to change sdk's index file somehow, because if i import a constant, it pulls everything from the sdk (i.e types, enums, clients, utils)
as alternative, we can add entrypoints to the package json like that:

{
  "exports": {
    ".": "./dist/index.js",
    "./enums": "./dist/enums.js",
    "./constants": "./dist/constants.js",
  }
}

this is a good modern practice, but still if i would accidentally import from the index file, it would pull everything from it.

@KirillKirill KirillKirill force-pushed the kb/dashboard-performance-check branch from 27ecfaf to fad7ba0 Compare July 10, 2025 13:47
@vercel vercel bot temporarily deployed to Preview – human-app July 10, 2025 13:47 Inactive
@vercel vercel bot temporarily deployed to Preview – staking-dashboard July 10, 2025 13:47 Inactive
@KirillKirill KirillKirill merged commit 2553a28 into develop Jul 10, 2025
27 checks passed
@KirillKirill KirillKirill deleted the kb/dashboard-performance-check branch July 10, 2025 13:55
@KirillKirill KirillKirill mentioned this pull request Jul 10, 2025
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants