Using UglifyJS's screw-ie8 Option in Gulp
UglifyJS writes JavaScript that works around IE 6-8 quirks by default. If you're building a modern app, those workarounds add bloat. The screw-ie8 flag tells UglifyJS to skip compatibility checks and produce smaller, faster code.
Without this flag, UglifyJS preserves behavior IE8 expects—like how try/catch affects variable scope or how named function expressions work. These workarounds add bytes to your bundle and slow down modern browsers. You're shipping compatibility code for a browser that died years ago.
From the command line:
cat input.js | uglifyjs --screw-ie8 -o output.js
Setting it up in Gulp
Here's the full Gulp task:
var minifier = require('gulp-uglify/minifier')
var uglifyjs = require('uglify-js')
var rename = require('gulp-rename')
gulp.task('uglify', function () {
return gulp.src(['js/*.js'])
.pipe(minifier({
compress: {
screw_ie8: true
},
mangle: {
screw_ie8: true
}
}, uglifyjs))
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('dist'))
})
I'm using gulp-uglify/minifier instead of the standard gulp-uglify. This lets me pass my own uglify-js version for more control. The screw_ie8 flag needs to be set in both compress and mangle to fully remove IE8 compatibility code. gulp-rename adds .min to the filename so original and minified versions coexist.
With screw_ie8: true, UglifyJS removes workarounds for IE8's broken try/catch scoping, handles named function expressions normally, produces shorter variable names without IE8 reserved word restrictions, and skips IE8-specific edge cases. The result: smaller bundles and faster execution in every browser that matters.
In 2016, IE8 usage was already negligible. Microsoft ended support in January 2016. This flag is about making a choice: support modern browsers well, or support dead browsers poorly. The right choice is modern.
Microsoft understood this too. That same year, Edge 14 caught up with Firefox on web standards, showing they were finally moving past the IE era.
Build tools have evolved since 2016. Gulp is still around, but modern alternatives like Vite handle minification with less configuration and better performance.