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

Considering the benefits of monkey patching


Okay, so we've seen what a typical patch will look like; the question, though, is, why would we want to patch the core library functionality using this method?

This is a very good question—it's a method that has its risks (as we will see later in this chapter, in the Considering the pitfalls of monkey patching section). The key to using this method is to take a considered approach; with this in mind, let's take a moment to consider the benefits of duck punching jQuery:

  • We can replace methods, attributes, or functions at runtime, where they lack functionality or contain a bug that needs to be fixed and we can't wait for an official patch

  • Duck punching jQuery allows you to modify or extend the existing behavior of jQuery without maintaining a private copy of the source code

  • We have the safety net of being able to apply a patch to objects running in memory, instead of the source code; in other words, if it goes completely wrong, we can simply pull the...