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

@import minimization #218

Closed
eGavr opened this issue Jan 29, 2014 · 3 comments
Closed

@import minimization #218

eGavr opened this issue Jan 29, 2014 · 3 comments

Comments

@eGavr
Copy link

eGavr commented Jan 29, 2014

Sometimes such situation happens:


@import "mystyle1.css";
a { color: #fff }
@import "mystyle2.css";
b { color: #00f }
@import "mystyle1.css";

Now it is minimized to


@import "mystyle1.css";a{color:#fff}@import "mystyle2.css";b{color:#00f}@import "mystyle1.css";

But according to CSS Specification all @import rules must precede all other rules (except the @charset rule, if present), so the previous css-code could be minimized to


@import "mystyle1.css";a{color:#fff}b{color:#00f}

@GoalSmashers
Copy link
Contributor

It is a bit more complex than that because according to W3 spec all @import statements must stay on top of CSS file. Thus moving them up to the top could change styling.
http://www.w3.org/TR/CSS21/cascade.html#at-import

And as an optimization tool we shouldn't be try to fix author's errors as it may lead to unexpected side effects.

@eGavr
Copy link
Author

eGavr commented Jan 31, 2014

Yes! We can't move @import statements on top of CSS file, such a thing can break it, BUT in order for better minimization cleancss could remove all @import statement, which are situated not on the top of the file. (as I've showed in the previous example), there is no need to move @import! W3 spec allows to remove incorrectly written @imports

@GoalSmashers
Copy link
Contributor

That's a valid point indeed. We should get rid of extra @imports.

On 31 Jan 2014, at 09:38, Evgeniy Gavryushin notifications@github.com wrote:

Yes! We can't move @import statements on top of CSS file, such a thing can break it, BUT in order for better minimization cleancss could remove all @import statement, which are situated not on the top of the file. (as I've showed in the previous example), there is no need to move @import! W3 spec allows to remove incorrectly written @imports


Reply to this email directly or view it on GitHub.

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

No branches or pull requests

2 participants