Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Sub-issue of #1190252: [573] Use csslint as a weapon to beat the crappy CSS out of Drupal core
Inline with the CSS cleanup efforts of the HTML5 initiative, using CSSLint at http://csslint.net provides a quick way to code-sniff our css and tweak styles.
- Copy and paste the the stylesheet(s) below into the css lint tool at http://csslint.net and test.
- Fix any warnings or errors the tool finds.
- Patch Drupal 8 locally and make sure the css changes have not broken anything visually.
- Create patch and upload for the testbot.
Files: modules/taxonomy/taxonomy.css
Comment | File | Size | Author |
---|---|---|---|
#2 | taxonomy-css-csslint-cleanup-1663192-2.patch | 523 bytes | Manuel Garcia |
Comments
Comment #1
RobLoachFrom https://gist.github.com/3006391
Comment #2
Manuel Garcia CreditAttribution: Manuel Garcia commentedHere's a patch blindly implementing csslint suggested changes.
Comment #3
RobLoachrob@Computron /var/www/drupal/8 $ node ../../csslint/release/npm/cli.js core/modules/taxonomy
csslint: No errors in core/modules/taxonomy/taxonomy.css.
Comment #4
webchickI really need someone who actually knows what's going on here to review the patch and confirm the changes here are good, and why. I don't mind committing a lot of these, but I want to understand what's happening, and everything here seems like it's just running it through a tool and saying "ok."
Comment #5
RobLoachCSSLint is a tool to test and clean up your CSS. You can read about what it helps with over in the Rules. Parsing the CSS with this will help improve browser render performance, and help clean up issues that would otherwise be missed.
Essentially what we're doing here is:
Comment #6
webchickYes, I understand the mechanics of all that. :P My question is, What are these specific CSS changes doing, and why is it good?
Comment #7
RobLoachThis particular issue cleans up overqualified elements.
Comment #8
droplet CreditAttribution: droplet commentedActually, it is duplicated (a part of) HTML5 cleanup. Compare to HTML5 CLEAN UP, it provided a standard tool to check the problem. I do suggest to close all duplicated issues: http://drupal.org/node/1190252#comment-6171090.
Comment #9
webchickThanks; so according to the referenced link this is a small performance improvement by having a less-specific class selector, because it doesn't need to find the element first, then find the specific class.
I'm not sure what #8 means. But this seems simple enough.
Committed and pushed to 8.x. Thanks!
Comment #10
Manuel Garcia CreditAttribution: Manuel Garcia commentedAvoiding overqualified elements is only being suggested in order to reduce filesize, afaik. I don't think we should just implement every case where csslint is suggesting it.
At least in this case, I don't see anyone re-using the same classes on other html elements so I think we can safely asume it's ok to not specify the element in the css selector.
We could however run into trouble if the class names are more generic and could be perhaps used elsewhere by people on their own sites. In these cases we should keep the "overqualified elements" selectors. Of course, how to determain which is which is a different story, I suggest we use common sense and a bit of hope =)