S
S
Sergey Gromov2016-07-04 11:55:36
JavaScript
Sergey Gromov, 2016-07-04 11:55:36

Unglify does not optimize, but increases the size by 2 times.. WTF?

Why does Unglify not optimize but increase the size by 2 times..?
here are 2 tasks. normal version without compression, but minified with uglify plugin.

//js
gulp.task('js', function() {
    gulp.src('js/*.js')
    .pipe(sourcemaps.init())
    .pipe(concat('script.js'))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('../js'))
});

//js.min
gulp.task('jsMin', function() {
    gulp.src('js/*.js')
    .pipe(sourcemaps.init())
    .pipe(concat('script.min.js'))
    .pipe(uglify())
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('../js'))
});

and that's what happened.
0af984d0a9fd45738f3c69ceaccf61af.jpeg
and if I put .pipe(uglify()) first in the task, then the size changes a little, but anyway, the minified version weighs more ... Tell me
aaecfd698e444d6ab1cc92634f2e71fa.jpeg
how or what to correctly press JS, it somehow turns out strange :))

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2016-07-04
Protko @Fesor

.pipe(sourcemaps.write())

here is the answer to your question. Your sourcemap is written directly to the resulting file. Keep her close and you'll be fine.

F
fetis26, 2016-07-04
@fetis26

It confuses me that you are running the already optimized version of jQuery and possibly other libraries with the optimizer. Try it on your original files only

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question