divriots / jampack

Optimizes static websites for best user experience and best Core Web Vitals scores.

Home Page:https://jampack.divriots.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

image.compress = false still compresses images

m-radzikowski opened this issue · comments

Hey,
first of all - jampack is great. All optimizations gathered in one command ❤️

I have one problem, however. The image.compress flag seems to disable image conversion (to webp or progressive jpeg), not image compression. I've already optimized images in the quality I want, so I don't want to re-processing them. But with this config:

export default {
	image: {
		compress: false,
	},
};

the output is:

 Summary 
╔════════╤════════════╤═══════════╤════════════╤════════════╗
║ Action │ Compressed │  Original │ Compressed │       Gain ║
╟────────┼────────────┼───────────┼────────────┼────────────╢
║ .webp  │ 354 / 1004 │  37.80 MB │   25.03 MB │  -12.77 MB ║
║ .svg   │      2 / 3 │  11.32 KB │    8.89 KB │   -2.43 KB ║
║ .html  │    86 / 87 │   3.46 MB │    3.45 MB │  -14.23 KB ║
║ .css   │      1 / 1 │  41.88 KB │   40.20 KB │   -1.68 KB ║
║ .js    │      2 / 2 │  19.38 KB │   19.37 KB │   -13.00 B ║
║ .png   │    58 / 73 │   6.94 MB │    6.73 MB │ -220.82 KB ║
╟────────┼────────────┼───────────┼────────────┼────────────╢
║ Total  │ 503 / 1181 │  49.36 MB │   36.36 MB │  -13.00 MB ║
╚════════╧════════════╧═══════════╧════════════╧════════════╝

So jampack compresses webp and png images. I would expect that with the flag compress = false it won't touch image files at all.

Even with the config based on the fast preset:

export default {
	image: {
		compress: false,
		srcset_min_width: 99999,
		embed_size: 0,
		jpeg: {
			options: {
				mozjpeg: false,
			},
		},
		png: {
			options: {
				compressionLevel: 0,
			},
		},
		webp: {
			options_lossless: {
				effort: 0,
				mode: "lossless",
			},
			options_lossly: {
				effort: 0,
				mode: "lossless",
			},
		},
	},
};

It still touches 2 webp files for some reason:

 Summary 
╔════════╤════════════╤═══════════╤════════════╤═══════════╗
║ Action │ Compressed │  Original │ Compressed │      Gain ║
╟────────┼────────────┼───────────┼────────────┼───────────╢
║ .webp  │   2 / 1004 │  37.80 MB │   37.80 MB │  -1.92 KB ║
║ .svg   │      2 / 3 │  11.32 KB │    8.89 KB │  -2.43 KB ║
║ .html  │    86 / 87 │   3.46 MB │    3.45 MB │ -14.23 KB ║
║ .css   │      1 / 1 │  41.88 KB │   40.20 KB │  -1.68 KB ║
║ .js    │      2 / 2 │  19.38 KB │   19.37 KB │  -13.00 B ║
║ .png   │     0 / 73 │   6.94 MB │    6.94 MB │           ║
╟────────┼────────────┼───────────┼────────────┼───────────╢
║ Total  │  93 / 1181 │  49.36 MB │   49.34 MB │ -20.28 KB ║
╚════════╧════════════╧═══════════╧════════════╧═══════════╝

The only way to skip image compression whatsoever is with the CLI --exclude flag:

jampack --exclude '**/*.{webp,png,gif,jpg,jpeg,mp4}' ./dist

Hi!

Yes that's because jampack has a second pass that compress all assets.
The configuration only controls the images processed in pass1 : optimizing.
https://jampack.divriots.com/features/compress-all/

You can disable pass 2 completely but then you don't have html, css or js minification.
https://jampack.divriots.com/cli-options/

Using the --exclude option, like you did, is the right way to do it today.

I will keep this open and maybe make the image.compress option apply to pass 2 automatically 👍

Done! image.compress config also use in pass 2
thanks for reporting