This modules is no longer being maintained.
Consider migrating to Advanced CSS/JS Aggregation
This module automatically runs CSSTidy using the highest compression template when CSS optimization is enabled in the Performance settings. It can also be configured to make the stylesheet readable using minimal linebreaks while still significantly compressing it. The default Drupal optimization removes whitespace around separators and comments that are not CSS hacks. This leaves much to be desired, especially considering it doesn't effectively remove all unnecessary whitespace is some instances. CSSTidy improves upon this by optimizing the stylesheet in the following ways:
- Colors like
blackorrgb(0,0,0)are converted short-hand hex-codes like#000when possible. Some hex-codes are replaced by their color names if they are shorter (#f00becomesred) a{property:x;property:y;}becomesa{property:y;}(all duplicate properties are merged)margin:1px 1px 1px 1px;becomesmargin:1px;margin:0px;becomesmargin:0;a{margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;}becomesa{margin:10px;}margin:010.0px;becomesmargin:10px;- All unnecessary whitespace is removed
- All
background:properties are merged - All comments are removed
- The last semicolon in every block is removed
- Missing semicolons are added, incorrect newlines in strings are fixed, missing units are added, bad colors (and color names) are fixed
property:value ! important;becomesproperty:value !important;
Why optimize?
If you optimize your CSS code you have faster loading pages and lower traffic costs. So both you and your visitors benefit from an optimization. Be sure to also try out the following modules which are compatible with CSSTidy:
- CSS Gzip or Boost - Compress .css files using gzip
- CSS Embedded Images - Reduce http requests by embedding images in stylesheet.
- CDN or Parallel - Changes the source of css files so users can download them faster.
Known Issues
Pressflow
CSSTidy is not currently compatible with Pressflow.
See Pressflow bug: #597718: file.inc function file_create_url() not correct
Hacks that work
The following is a list of all CSS hacks that will not be modified by CSSTidy. In general, you shouldn't use CSS hacks, but if you need them and want to use CSSTidy you should use one of the following hacks:
- div#test
- head:first-child+body div
- body>div
- html[xmlns] div
- @import "null?\"\{"; @import "styles.css"; (and all other @import rules)
- @media all{/* rules */}
- * html div
- i{content:"\"/*"} div{property:value}
- html*#test
- _property:value
- *property: value;
Special Thanks to...
- floele and sunnybear - For their hard work on the CSSTidy project
- jcarnett - Because this module is heavily based on his work on CSS Embedded Images
Downloads
Recommended releases
Other releases
Development releases
Project Information
- Maintenance status: Unsupported
- Development status: No further development
- Module categories: Performance and Scalability
- Reported installs: 161 sites currently report using this module. View usage statistics.
- Downloads: 3,039
- Last modified: July 13, 2011