Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused classnames #472

Closed
briannhinton opened this issue Jun 16, 2021 · 2 comments · Fixed by #484
Closed

Remove unused classnames #472

briannhinton opened this issue Jun 16, 2021 · 2 comments · Fixed by #484
Assignees
Labels
feat: styling Related to styles (scope)

Comments

@briannhinton
Copy link
Contributor

What is Missing from Astro Today?

Remove unused classnames (ie. astro-feHumnd) as a final optimization step on build.

Proposed Solution

Noted by: @drwpow these will probably stay in dev no matter what because there are a lot of weird behaviors when you try and treeshake something almost as a race condition with other stuff happening on-the-fly.

But as a final build step when we know what the final HTML & CSS is only necessary classnames should persist.

@FredKSchott FredKSchott added this to Needs Triage in 🐛 Bug Tracker via automation Jun 17, 2021
@FredKSchott FredKSchott moved this from Needs Triage to Feature Request in 🐛 Bug Tracker Jun 17, 2021
@matthewp matthewp added the feat: styling Related to styles (scope) label Jun 17, 2021
@natemoo-re
Copy link
Member

One straight-forward optimization here would be to not apply the astro-xxxxx class if the component has not <style> block. But I definitely agree that we could try to purge the classes as a final build optimization.

@FredKSchott
Copy link
Member

tbh #497 is plenty for where we are at right now. Anything more I think would require the ability to really parse your CSS, which I know @drwpow had mentioned wanting to avoid for now.

A reminder for anyone concerned about perf: a reused classname gzips REALLY well. This probably has less affect on loading perf than you'd think, especially once #497 is merged.

natemoo-re added a commit that referenced this issue Jun 19, 2021
* feat(#472): do not inject `astro-xxx` class for components without styles

* test: add test for skipped scoped classes

* chore: add changeset

* Update happy-cougars-scream.md
🐛 Bug Tracker automation moved this from Feature Request to Done Jun 21, 2021
SiriousHunter pushed a commit to SiriousHunter/astro that referenced this issue Feb 3, 2023
…astro#497)

* feat(withastro#472): do not inject `astro-xxx` class for components without styles

* test: add test for skipped scoped classes

* chore: add changeset

* Update happy-cougars-scream.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: styling Related to styles (scope)
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

5 participants