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

Linting jQuery code automatically


Linting code, or checking it for errors, is an essential part of jQuery development. Not only does it help get rid of the errors, it also helps identify the code that isn't being used within the script.

Don't forget – optimizing isn't just about adjusting selectors or even replacing jQuery code with CSS equivalent (as we saw in Chapter 6, Animating with jQuery). We need to first ensure that we have a solid base to work from – we can always do this manually, but the smarter option is to automate the process using a task runner such as Grunt.

Let's take a moment to see how this works in action – note that this assumes you still have NodeJS installed from previous exercises. This time around, we will use it to install the grunt-contrib-jshint package, available from https://github.com/gruntjs/grunt-contrib-jshint:

  1. Setting up the automatic check is very easy. To start, we need to download and install grunt-contrib-jshint. Open up a NodeJS command prompt, and enter...