Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
251 views
in Technique[技术] by (71.8m points)

reactjs - Loading critical CSS in Next.js

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...