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

Working out unused JavaScript


So far, we've seen how we can easily minify code without any effort – but what if minifying isn't enough, and we need to remove redundant code?

Well, we can manually eyeball the code – nothing wrong with that. It's a perfectly acceptable way of working out what we can remove. The key thing though is that it is a manual process, which requires a lot of time and effort – not to mention the frequent attempts to find code that we can remove without breaking something else!

A smarter move is to set Node to work out for us what is being used, and what could be safely dropped. The web performance expert Gaël Métais has created unused JS to help with this. It works with Node, and is available at https://www.npmjs.com/package/unusedjs. It's a work in progress, but as long as it is used as a guideline, it can produce a useful basis for us to work out where we can make changes.

Let's take a moment to dig in and see how it works. For this demo, we'll use the Tooltip plugin...