From 73ca5bebdd0a3c10a3b49c2acab48008e0fe5fdf Mon Sep 17 00:00:00 2001 From: "Thomas F. K. Jorna" Date: Tue, 21 Nov 2023 20:46:42 +0100 Subject: [PATCH 1/2] feat: change hydration data to be smaller --- client/utils/hydrateWrapper.tsx | 4 ++-- client/utils/initialData.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/utils/hydrateWrapper.tsx b/client/utils/hydrateWrapper.tsx index 521762d4de..5a07eb30b0 100644 --- a/client/utils/hydrateWrapper.tsx +++ b/client/utils/hydrateWrapper.tsx @@ -32,10 +32,10 @@ export const hydrateWrapper = (Component) => { } // @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'. - const viewData = JSON.parse(document.getElementById('view-data').getAttribute('data-json')); + const viewData = JSON.parse(document.getElementById('view-data')?.innerText); const chunkName = JSON.parse( // @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'. - document.getElementById('chunk-name').getAttribute('data-json'), + document.getElementById('chunk-name').innerText, ); if (!isLocalEnv(window)) { setupHeap(initialData); diff --git a/client/utils/initialData.ts b/client/utils/initialData.ts index b777f10ae2..9a91e09d23 100644 --- a/client/utils/initialData.ts +++ b/client/utils/initialData.ts @@ -5,7 +5,7 @@ let initialData; export const getClientInitialData = () => { if (!initialData) { // @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'. - initialData = JSON.parse(document.getElementById('initial-data').getAttribute('data-json')); + initialData = JSON.parse(document.getElementById('initial-data').innerText); } return initialData; }; From ca1cf8351ab1fc0b2751edfec358abc37318f648 Mon Sep 17 00:00:00 2001 From: "Thomas F. K. Jorna" Date: Tue, 21 Nov 2023 20:58:21 +0100 Subject: [PATCH 2/2] feat: really minify body --- server/Html.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/server/Html.tsx b/server/Html.tsx index 91f337878e..23dee69f92 100644 --- a/server/Html.tsx +++ b/server/Html.tsx @@ -2,7 +2,7 @@ import path from 'path'; import React from 'react'; import classNames from 'classnames'; import App from 'containers/App/App'; -import { CustomScripts, InitialData } from 'types'; +import type { CustomScripts, InitialData } from 'types'; const manifest = require(path.join( __dirname, @@ -123,19 +123,20 @@ const Html = (props: Props) => { />