3

Is there a way in Next.js to separate critical CSS and non critical for each page and load non-critical asynchronously ?

I am using styled-components in my pages and components + couple of external css libraries.

Thanks!

1 Answer 1

1

You can use module css, but not global. Global styles can only be used in _app.js, but you can import "module" css which is a built in feature. Is this what you mean?

// Foo.js component needing third party

import '@thirdparty/dist/styles.css'

// Foo.js component with module css from you

import styles from "./Foo.module.css";

I apologize if this is not what ur looking for. I'm not entirely sure what you are in need of.

Sign up to request clarification or add additional context in comments.

1 Comment

How to load critical styles as inline in Next.js?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.