Skip to content

CSS Styles from unrelated pages and components are merged if they're using the same shared component #70168

Answered by sokra
Obvio asked this question in Help
Discussion options

You must be logged in to vote

Even with CSS Modules order matters in same cases. E. g. when applying styles from two different CSS modules to the same element:

import stylesA from "./a.module.css";
import stylesB from "./b.module.css";

<div className={stylesA + " " + stylesB}>

This often happens with components that allow to pass a className prop.

On a personal opinion - I feel site visitors are more inclined to stay on the site (not bounce) if the first experience is super fast (the rest of the site's css can be lazyloaded).

Agree. We usually optimize with the focus on initial page load, but here we have to make trade-offs for correctness.

There is an alternative approach for CSS we experimented with for Turbopack…

Replies: 4 comments 23 replies

Comment options

You must be logged in to vote
5 replies
@Obvio
Comment options

@sokra
Comment options

@Obvio
Comment options

@sokra
Comment options

Answer selected by Obvio
@Obvio
Comment options

Comment options

You must be logged in to vote
10 replies
@joshwcomeau
Comment options

@marko-hologram
Comment options

@joshwcomeau
Comment options

@samcx
Comment options

@marko-hologram
Comment options

Comment options

You must be logged in to vote
5 replies
@joostmeijles
Comment options

@samcx
Comment options

@joostmeijles
Comment options

@samcx
Comment options

@joostmeijles
Comment options

Comment options

You must be logged in to vote
3 replies
@joshwcomeau
Comment options

@joshwcomeau
Comment options

@samcx
Comment options

samcx Jan 2, 2025
Maintainer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
bug Issue was opened via the bug report template.
6 participants
Converted from issue

This discussion was converted from issue #70120 on September 16, 2024 23:33.