After running an audit, Lighthouse is advising me to "Defer unused CSS" for my React app. Despite implementing code splitting and having separate CSS files for each chunk, the suggestion persists. One particular example highlighted by Lighthouse is the footer chunk. The footer component is lazy loaded using react-lazyload
, meaning it will only load when scrolling down the page.
The issue arises as the CSS associated with the footer component is still being loaded into the head of the page even though the component itself is not rendered initially. This is what Lighthouse is flagging as problematic.
Is there a way to delay loading the CSS into the head until the specific component is actually rendered or needed?
Just to provide context, I am operating within a non-ejected Create React App (CRA) environment.