Answer the question
In order to leave comments, you need to log in
How to "merge" a bunch of js files into one?
Hello. The number of js libraries exceeded the sane number and began to really slow down the loading of the site. I tried to combine it with my hands, but nothing good comes of it - errors come up.
How is it done correctly?
Answer the question
In order to leave comments, you need to log in
cat 1.js 2.js 3.js > all.js
or in Makefile:
src/all.js: $(wildcard src/*.js)
cat $^ > [email protected]
UGLIFY = uglifyjs
...
src/all.js: $(wildcard src/*.js)
cat $^ | $(UGLIFY) -cmo [email protected]
UglifyJS .
-c = compress, compression
-m = mangle, "mangle" names of variables and functions.
-o = output file name
uglifyjs jquery.js bootstrap.js mylib.js myapp.js -c -m -o compiled.js
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question