Conclusion

This lesson introduced you to writing reusable code that extends jQuery. Writing your own code as extensions to jQuery has a number of advantages. Not only does it keep your code consistent across your web application regardless of whether it’s employing jQuery APIs or your own, but it also makes all of the power of jQuery available to your own code.

Following a few naming rules helps avoid naming collisions between filenames and with other plugins’ code, as well as problems that might be encountered when the $ name is reassigned by a page that will use your plugin. In addition, you’ve seen how you can build plugins that don’t break jQuery’s chainability.

Creating new utility functions is as easy as creating new function properties on $, and new jQuery methods are easily created as properties of $.fn.

If plugin authoring intrigues you, we highly recommend that you download and comb through the code of existing plugins to see how their authors implemented their own features. You’ll see how the techniques presented in this lesson are used in a wide range of plugins, and you’ll even learn new techniques.

Having yet more jQuery knowledge at your disposal, let’s move on to learning how you can use jQuery to better manage asynchronous functions.


by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *