sindresorhus / gulp-webp

Convert images to WebP
MIT License
220 stars 18 forks source link

Too slow? #27

Open notiv-nt opened 5 years ago

notiv-nt commented 5 years ago

gulpconfig

const gulp = require('gulp');
const webp = require('gulp-webp');

gulp.task('img', () => {
  return gulp
    .src('src/*')
    .pipe(webp())
    .pipe(gulp.dest('dist'));
});

package.json

{
  "dependencies": {
    "gulp": "^4.0.2",
    "gulp-webp": "^4.0.1"
  }
}

src 12.9mb

image

dest 6.7mb (52%)

image

console

image

15 seconds? Why so slow?

In realtime:

1

notiv-nt commented 5 years ago

Heh? The same but with native imagemin:

2

notiv-nt commented 5 years ago

One more thing:

const gulp = require('gulp');
const webp = require('gulp-webp');
const imagemin = require('gulp-imagemin');
const imageminWebp = require('imagemin-webp');
const rename = require('gulp-rename');

gulp.task('img', () => {
  return gulp
    .src('src/*')
    .pipe(webp())
    .pipe(gulp.dest('dist'));
});

gulp.task('img-min', () => {
  return gulp
    .src('src/*')
    .pipe(imagemin([imageminWebp()]))
    .pipe(rename({ extname: '.webp' }))
    .pipe(gulp.dest('dist'));
});

  1. npx gulp img 12s
  2. npx gulp img-min 2.7s
jamesryan-dev commented 3 years ago

Thanks for this @notiv-nt +1 indeed

mihail-minkov commented 2 years ago

Excellent contribution @notiv-nt it made a drastic difference in my optimization times:

Before image

Now image