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

Generated CSS is big #555

Closed
vardanabhanot opened this issue Feb 22, 2023 · 8 comments
Closed

Generated CSS is big #555

vardanabhanot opened this issue Feb 22, 2023 · 8 comments

Comments

@vardanabhanot
Copy link

vardanabhanot commented Feb 22, 2023

So I tried to generate critical CSS, but the CSS is like 30,000 characters big. And I tested it with css-tricks.com and it was giving error.
the error I am getting with css-tricks.com is
/index.html.css:2:4: Unknown word

And the configuration I am using is
generate({ base: "critical_css/" + basename, src: url, target: { css: "critical.css", }, width: 1300, height: 900, extract: true, });

Do I need to do something in the config to make it work?
And it is also including inlined CSS too

@bezoerb
Copy link
Collaborator

bezoerb commented Mar 1, 2023

Hey, thanks for using critical:-)
The config looks fine to me... can you post a link to the project or is it private? Otherwise an example which makes it possible to reproduce the issue would be helpful

@vardanabhanot
Copy link
Author

Hello,

Just use the above config, as I was just using that and nothing more. And try it on css-tricks.com first, you will be able to reproduce that.
As I later tried to use penthouse directly and everything was working fine in it, so the issue is most probably in the style linter

@bezoerb
Copy link
Collaborator

bezoerb commented Apr 9, 2023

Hey @vardanabhanot,

i tried with css-tricks and i got the same error. The error is caused by an invalid inlined stylesheet
image

This is fixed in the linked PR.
Regarding the Big resulting critical css i would need to take a look at the original files to debug this

@bezoerb
Copy link
Collaborator

bezoerb commented Apr 9, 2023

Would you test again using the latest version v5.1.0?

@onlinebizsoft
Copy link

Look like the tool includes all declaration (even overwritten ones) for every element in the above-the-fold area.
For example we have an element and it has multiple font declaration applied so only one is active and get used but look like all applicable rules will be included

@bezoerb
Copy link
Collaborator

bezoerb commented Sep 15, 2023

@onlinebizsoft could you try again with v5.2.0
I added an option to customize cleancss. See https://github.com/clean-css/clean-css#optimization-levels

@bezoerb
Copy link
Collaborator

bezoerb commented Jan 27, 2024

I'm closing this due to lack of feedback.
Feel free to reopen if there are new insights

@bezoerb bezoerb closed this as completed Jan 27, 2024
@onlinebizsoft
Copy link

Sorry I missed the new option. Let me check and get back when I have the result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants