Answer the question
In order to leave comments, you need to log in
Compression order in uglify?
I compress project js files with Grunt (concat, uglyfy).
In the resulting scripts.min.js file, the order of functions is reversed, functions do not see JQeury, and so on.
How to control the order when minimizing?
concat: {
main: {
src: [
'libs/jquery/dist/jquery.js',
'libs/jquery/dist/jquery.min.js',
'libs/bootstrap/dist/js/bootstrap.min.js',
'js/jquery.selectbox-0.2.min.js',
'libs/jquery-ui/jquery-ui.min.js',
'libs/jquery-json/dist/jquery.json.min.js',
'libs/tablesorter/dist/js/jquery.tablesorter.min.js',
'libs/jquery.autocomplete/jquery.autocomplete.min.js',
'libs/jquery-number-mask/dist/jquery.numberMask.min.js',
'libs/jquery-validation/dist/jquery.validate.min.js',
'libs/react/react.min.js',
'js/public.js',
'js/functions.js'
],
dest: 'build/scripts.js',
options: {
block: true,
line: true,
stripBanners: true
}
}
},
// Сжатие JS-файла
uglify: {
options: {
mangle: {
except: ['jQuery', 'Backbone']
}
},
main: {
files: {
'build/scripts.min.js': ['build/scripts.js']
}
}
}
Answer the question
In order to leave comments, you need to log in
1. Do not compress already compressed (.min) files.
2. Compress vendors separately from your files, as these files will change much less often and as a result will be taken from the browser cache.
3. You have jQuery written 2 times:
'libs/jquery/dist/jquery.js',
'libs/jquery/dist/jquery.min.js',
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question