我正在使用gulp-imagemin一段時間,但幾個月前我注意到我的壓縮圖像不滿意google的頁面速度。我嘗試了所有設置的組合,但沒有結果。也嘗試了imagemin-cli和直接jpegtran - 都是一樣的,在大圖像上它提供了2-5%的壓縮率,而tinyfy則提供了50%。當我使用某些雲優化器時(它可以提供正確的壓縮)。Imagemin對於谷歌頁面速度見解不夠?
我現在的任務,一飲而盡看起來像:
gulp.task('imagemin', function() {
return gulp.src(input_files)
.pipe(newer(output_path))
.pipe(imagemin([
imagemin.gifsicle({interlaced: true}),
imagemin.jpegtran({progressive: true}),
imagemin.optipng({optimizationLevel: 7}),
imagemin.svgo({plugins: [{removeViewBox: true}]})
],{verbose:true}).on('error', gutil.log))
.pipe(gulp.dest(output_path));
});
你試過srcset了嗎? https://developer.mozilla.org/de/docs/Web/HTML/Element/img#Example_3_Using_the_srcset_attribute – moesphemie
是的,但只適用於視網膜。我知道它適合大小斷點,但現在對於我來說很難改變工作流程,並根據響應規則製作多個圖像(一些圖像變小,一些更大的圖像寬度變得更小)。所以如果有些東西沒有手動調整圖像大小,那就太好了。請讓我知道你是否有解決方案。 – MadDocNC