kontent-starter-corporate-next-js icon indicating copy to clipboard operation
kontent-starter-corporate-next-js copied to clipboard

Implement loadable components

Open Simply007 opened this issue 3 years ago • 0 comments

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

Simply007 avatar Mar 29 '21 17:03 Simply007