Precompress CSS, JS and SVG files with gzip and Brotli
create files for nginx gzip_static | precompress assets with brotli | prepare static compression | generate css.gz and js.br files | gzip | brotli | compression | findCaution: This command changes the system. Understand what it does before you run it.
find /var/www/vhosts/example.com/httpdocs/wp-content/themes -type f \( -name '*.css' -o -name '*.js' -o -name '*.svg' \) -exec gzip -k -9 -f {} + -exec brotli -k -f {} +Creates a datei.css.gz and a datei.css.br next to the original at the highest compression level, keeping the original (-k). With gzip_static on, nginx serves such files directly without compressing again on every request. Existing compressed versions are overwritten (-f).
Note: Install the brotli package if needed. For .br, nginx needs the Brotli module with brotli_static. Run it again after every change to the originals, otherwise the server delivers outdated versions.
Also searched as
- create files for nginx gzip_static
- precompress assets with brotli
- prepare static compression
- generate css.gz and js.br files