Chapter 2

Libraries, Frameworks, and Plugins

In addition to following best practices, you should build your app on a solid foundation of libraries and plugins. Sure, you could write everything yourself, and there is indeed a time and place for that. But in most cases, it makes more sense to rely on the open-source work released by other developers.

Libraries and plugins can help speed up your development process and jumpstart your app with a boilerplate of basic functionality. Best of all, the well-known libraries have a huge community behind them, with excellent developers writing and rewriting the code, and a vast user base uncovering any bugs. With the more established, tried and tested libraries out there, you can be confident in using them in your application.

Plugins, on the other hand, are a little spottier when it comes to code quality. A good plugin saves you loads of time, while a bad plugin may end up creating more problems than it solves (and force you to spend more time debugging it than you would have spent writing it from scratch).

In this chapter, you discover how to choose the right JavaScript library for your project. I compare jQuery, Zepto, and writing your own vanilla JavaScript. Then you learn about the larger frameworks Bootstrap and jQuery UI. After briefly discussing how Modernizr can streamline cross-browser CSS issues, I show how HTML5 Shiv builds support for HTML5 elements in older browsers.

Next, I discuss HTML5 Boilerplate, which is neither a library ...

Get JavaScript Programming: Pushing the Limits now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.