MINIFY JAVASCRIPT FILES & FOLDERS in Multiple Ways (Command Line & Code Editor)

Опубликовано: 03 Июнь 2022
на канале: WebStylePress
11,929
116

Minify JavaScript files and JavaScript files in folders. It can be done by using code editor - easily - also. From visual studio code, install an extension called minify. Open JS file, open command palette using ctrl + shift + p keys, type minify, select minify, and file is minified and saved in same directory. This is cool but let's do it by using npm or command line. You should have NodeJS installed in system to do it.

Open terminal (I am using git for Windows)
Type npm init and answer questions and get the package.json file
Install package uglifyjs (uglify-js) for dev environment
Inside scripts in package json file create commands

I have also explained about flags for different packages.

c flag means compress
m flag means mangle - mangle will further simplify the output - it will be less human readable but efficient for machines to read
o is for the output file or directory

You can read more about these flags from uglifyjs docs.

Use uglify and mention input output file and flags to minify js file.

How about converting multiple JavaScript files from a folder?

Install package uglifyjs folder (uglifyjs-folder) and create script to convert javascript folder into minified js files.

e means minify each file independently
o is for the output file or directory

Can we get the minified JS output in one JS file from multiple JavaScript files from a folder?

We can mention file name as output instead of folder name to get minified file from multiple js files from a folder. This will take all javascript files from folder and minify them into one javascript file.

And this is how you can minify javascript files by using command line in multiple ways.

Time Stamps:
00:00 INTRO
00:10 Minify JavaScript files using code editor
01:12 Install Package to minify JS file
02:12 Minify single JavaScript file using command line
03:36 Minify multiple JavaScript files from a folder individually
05:44 Minify multiple JavaScript files from a folder into single minified file

Thank You!
👍 LIKE VIDEO
👊 SUBSCRIBE
🔔 PRESS BELL ICON
✍️ COMMENT

Channel:    / webstylepress  
Website: https://www.webstylepress.com
FaceBook:   / webstylepress  
Twitter:   / webstylepress  
GitHub: https://github.com/webstylepress
#npm #js #javascript #minify #minjs #WebStylePress #uglifyjs #uglifyjsFolder #webdevelopment


Смотрите видео MINIFY JAVASCRIPT FILES & FOLDERS in Multiple Ways (Command Line & Code Editor) онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь WebStylePress 03 Июнь 2022, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 11,929 раз и оно понравилось 116 людям.