Book Image

Mastering jQuery

By : Alex Libby
Book Image

Mastering jQuery

By: Alex Libby

Overview of this book

<p>Mastering jQuery has been written not only to help maximize your skills with core functionality in the library, but also to explore some of the more intriguing ways of using the library to achieve real-world solutions that could feature on any website or online environment.</p> <p>You'll start with a look at some of the more advanced ways to incorporate the library into your pages, followed by working with forms and advanced form validation using regular expressions. Next you'll move on to animating in jQuery, advanced event handling, and using jQuery effects.</p> <p>Finally, you will develop practical examples of using jQuery with external functionality such as node-webkit, before finishing with a session on optimizing your version of the library for maximum efficiency and exploring best practices for using QUnit.</p>
Table of Contents (21 chapters)
Mastering jQuery
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Minifying code using NodeJS


A key part of any developer's workflow should be a process to minify the scripts used in a site. This has the benefit of reducing the size of the downloaded content to a page.

We can of course do this manually, but it's a time consuming process which adds little benefit; a smarter way is to let NodeJS take care of this for us. The beauty of doing this means that we can configure Node to run with a package such as grunt-contrib-watch; any changes we make would be minified automatically. There may even be occasions when we decide not to produce a minified file; if we're unsure that the code we are writing is going to work. At times like this, we can instead fire off Grunt from within our text editor, if we're using a package such as Sublime Text.

Tip

If you want to implement that level of control within Sublime Text, then take a look at sublime-grunt, available from https://github.com/tvooo/sublime-grunt.

Okay, let's start with setting up our minification process. For...