Uglify

John Lindquist
InstructorJohn Lindquist
Share this video with your friends

Social Share Links

Send Tweet
Published 11 years ago
Updated 5 years ago

In this lesson John will show you how to start using Grunt Uglify to compress your javascript for production deployment.

John Lindquist: Before we bring together all the watching, configuring, templating, and things like together, let's look at one more NPM task we want to install.

We want to do grunt-contrib-uglify. This one is going to download and install Uglify, which is used to concatenate and minify your files. We're going to keep it really basic here.

With Grunt, we want to load an NPM task of grunt-contrib-uglify, and then we're going to need a few files to uglify. We will create some JavaScript files. An app directory, and then I'll set up this dummy file, file one, file two, and file three.

Let's concatenate all these together, one, two, and three, into a minified version by configuring Uglify. We'll say Uglify, and then we need a target. We'll call this target-dist for "distribution, distributable." We need some files. We'll just go ahead and map the minified file, which can be dist/app.min.js, to the files we want to load in, which are going to be app and then every JavaScript file inside of app.

Once we run this, we can say grunt-uglify. Hit Enter. You can see. It says, "app.min.js was created."

We come up here, and we can see that we have app.min.js. We've just concatenated all of our files -- one, obviously alphabetically, three, and two.

egghead
egghead
~ 38 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today