kontent-starter-corporate-next-js
kontent-starter-corporate-next-js copied to clipboard
Implement loadable components
Motivation
Lighthouse reports that some components do not need to be a part of an initial bundle.
Proposed solution
Use this thing: https://webpack.js.org/api/module-methods/#dynamic-expressions-in-import in combination with gregberge/loadable-components
to make the component capable of async - it should be OK to SSR as well.
const OtherComponent = loadable(() => import('./OtherComponent')) + const x = import(./layout/${contentType}.js);
Think on blinks - layout might be “jumping“ https://loadable-components.com/docs/getting-started/ https://github.com/gregberge/loadable-components
Try to apply on https://github.com/Kentico/kontent-starter-corporate-next-js#content-types---react-components-mapping
Additional context
Avoid cumulative layout shift - CLS