perf: significantly reduce HTML we send to the client. Up to 4x smaller (#9321)

The biggest difference comes from calling `RenderServerComponent` as a
function, instead of rendering it by using `<RenderServerComponent`.

This gets rid of wasteful blocks of codes sent to the client that look
like this:

![CleanShot 2024-11-18 at 20 41
20@2x](https://github.com/user-attachments/assets/edb67d72-f4a5-459b-93f4-68dc65aeffb6)


HTML size comparison:

## Admin test suite

| View | Before | After |
|------|---------|--------|
| Dashboard | 331 kB | 83 kB |
| collections/custom-views-one Edit | 285 kB | 76.6 kB |

## Fields test suite

| View | Before | After |
|------|---------|--------|
| collections/lexical Edit | 189 kB | 94.4 kB |
| collections/lexical List | 152 kB | 62.9 kB |

## Community test suite

| View | Before | After |
|------|---------|--------|
| Dashboard | 78.9 kB | 43.1 kB |
This commit is contained in:
Alessio Gravili
2024-11-18 21:30:21 -07:00
committed by GitHub
parent 1425d58b57
commit 5d2b0b30b0
25 changed files with 456 additions and 515 deletions

View File

@@ -9,10 +9,10 @@ export const AfterDashboardClient: PayloadServerReactComponent<CustomComponent>
return (
<Banner>
<p>Admin Dependency test component:</p>
<RenderServerComponent
Component={payload.config.admin.dependencies?.myTestComponent}
importMap={payload.importMap}
/>
{RenderServerComponent({
Component: payload.config.admin.dependencies?.myTestComponent,
importMap: payload.importMap,
})}
</Banner>
)
}