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 pitfalls of monkey patching


Now that we've seen some examples in action, it's worth taking a moment to consider some of the risks of monkey patching libraries, such as jQuery:

  • The principle risk and one that is likely to cause the most trouble is clashing. Imagine that you've created a patch that contains some functions—we'll call these functions 1, 2, and 3. Add another patch, and it is essential that we do not use the same function names; otherwise, it's difficult to determine whether function 1, or 2, or even 3 comes first?

  • Another risk is security. If a library such as jQuery can be monkey patched, what is to stop anyone from introducing malicious constructs that damage the existing code? One can argue that this risk is always present in client-side scripting; the risk is greater when you override core jQuery functionality, compared to a standard plugin.

  • There is always a risk that an upgrade to the core library may introduce a change that not only breaks your patch but...