When I use the minify tool to compress my js
and css
files, I noticed that the files containing background:url(...)
statements actually increased in size. This happened because the urls were encoded to base64
.
I tried to disable this base64 encoding feature using the css-base64-images function, but it seems that it is not possible based on an issue raised back in 2016.
Here's a snippet from my package.json
:
"devDependencies": {
"minify": "^9.1.0",
"postcss-cli": "^10.0.0"
}
This is a part of my code:
import { minify } from 'minify';
const myFunction = () => {
/* some code... */
minify(filepath).then((file) => {
/* some code... */
});
}
According to an informative article, utilizing base64
for image optimization may not always be necessary. In my case, some css
files have ballooned to10,000 KB
from 40-50 KB
post-minification, prompting me to want to deactivate base64
.