Abdul Hanan
Abdul Hanan

Reputation: 98

WP COMPRESS_CSS

Can we compress our WP Develop Theme style sheets via define( 'COMPRESS_CSS', true ) like WP style or script concatenation?

Upvotes: 2

Views: 7103

Answers (2)

Phill Healey
Phill Healey

Reputation: 3180

An old question but it's not got an accepted answer so here goes....

define( 'COMPRESS_CSS', true )

This does all the compression at run-time and is performed by PHP. This essentially means that the web server holds back all the CSS files, then compresses them before delivering them to the browser.

Because, of this there is likely an associated time penalty which could mean it takes longer to load the page than if you'd not used the 'compress_css' constant. But, if you have a lot of CSS then it could save you some loading time. Obviously caching can have an impact too on whether this constant declaration offers any advantages or not.

Eitherway, it's far better to compress/minify your orginal CSS files for production releases of your theme/plugin. CSS minification is so easy to do and there are many online tools that will do it for you.

Upvotes: 5

PPL
PPL

Reputation: 6555

Several constants are used to manage the loading, concatenating and compression of scripts and CSS:

define('SCRIPT_DEBUG', true); //loads the development (non-minified) versions of all scripts and CSS, and disables compression and concatenation,

define('CONCATENATE_SCRIPTS', false); //disables compression and concatenation of scripts and CSS,

define('COMPRESS_SCRIPTS', false); //disables compression of scripts,

define('COMPRESS_CSS', false); //disables compression of CSS,

define('ENFORCE_GZIP', true); //forces gzip for compression (default is deflate).

Upvotes: 0

Related Questions