Unnecessary CSS being imported
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 15.1k
- Forks
- 1.9k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 143
Description
Which project does this relate to?
Start
Describe the bug
When using normal css imports or css modules, css from other routes is requested on the page load
Your Example Website or App
https://codesandbox.io/p/devbox/smoosh-platform-5ws8gt?workspaceId=ws_KBZbFGeuhMkBGc8o1kN3wx
Steps to Reproduce the Bug or Issue
From start basic example:
- Add a new css file
- Import that file from any route with a normal import, not using
?url - Create a production build (also happens in dev)
- Load the home page, here you can see that both css files are requested, and the newly created css file should only be requested in its own page, or on link hover.
this is demostrated in the codesandbox example
Expected behavior
Only the css file being used in that specific route being requested (only in users in this example)
Screenshots or Videos
No response
Platform
- OS:any
- Browser: any
- Version: latest
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Start basic example and reproduce the issue in both development and production builds. Inspect how normal CSS imports from routes become requested when the home page loads, then verify that only the CSS for the active route is requested, with the other route's CSS deferred until its page or link hover.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css, typescript
- Domain
- build-system, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100