Remove Duplicate CSS Selectors from the final content#236
Conversation
i noticed that if i add two of the same (or content) the script will still show them, and that will add up to the final file size (content).
for instance if i add default.css and default.css?v=1 and both have 'body{font-family:xx}, the final file will contain both files contents resulting in duplicate css selectors.
i added a method which gets all css selectors and array_unique that with implode of a NULL glue.
that will save a lot of data. for the example files i gave here it will cut the file size (and content) to half.
|
Out of curiosity. Does this properly handle overridden styles? E.g.: file1.css file2.css file3.css |
|
Also it seems this PR actually adds / changes two different unrelated things? You may want to split it up in 2 PRs if that is indeed the case. |
|
@PeeHaa this method will keep the last selectors (just like the browser). + i should make it clear that selectors must be identical in order to be removed since i'm using array unique on the list of all css selectors so it's not about a single property thing, it's about identical selector+properties+values |
|
@PeeHaa i noticed some changed cuz i'm using PHPStorm IDE, it reformatted parts of the code. |
Adding $options to minify, usefull for customizing behaviours, etc.
|
@PeeHaa about PRs, i'm actually new to github however i created a new branch for the customization thing and separated them, i hope i did it the right way. |
No worries. Looks fine to me. |
a3cbcc7 to
4762aed
Compare
Removing Duplicate CSS Selectors
i noticed that if i add two files of the same content, the script will still show them and that will add up to the final file size (content).
for instance if i add default.css and default.css?v=1 and both have body{font-family:xx}, the final file will contain both files contents resulting in duplicate css selectors.
i added a method which gets all css selectors and array_unique that will implode with a NULL glue.
that will save a lot of data. for the example files i gave here it will cut the file size (and content) to half.