Minimization + deflation / gzipping works great.
I use mod rewrite for this purpose, I previously created all the css / js files in version 2, the original and .css.gz / .js.gz.
The browser simply sends a .js / .css request, the server checks for the existence of .js.gz / .css.gz and returns gzipped content if certain conditions match.
So it doesnβt matter that the js / css file is loaded on the fly from js (for example, shadow or tint)
Basically like that
RewriteEngine On RewriteBase / #Check for browser Accept-Encoding, RewriteCond "%{HTTP:Accept-Encoding}" "gzip.*deflate|deflate.*gzip" #check file name is endswith css or js RewriteCond %{REQUEST_FILENAME} "\.(css|js)$" #check existance of .gz file name RewriteCond %{REQUEST_FILENAME}.gz -s #rewrite it to .js.gz or .css.gz RewriteRule ^.*$ %{REQUEST_URI}.gz [L] #update some response header <FilesMatch "\.js\.gz$"> AddEncoding gzip .gz ForceType "text/javascript" </FilesMatch> <FilesMatch "\.css\.gz$"> AddEncoding gzip .gz ForceType "text/css" </FilesMatch>
YOU
source share