Chapter 4. Bootstrap JavaScript Plugins
The components discussed in Chapter 3 are just the beginning. Bootstrap comes bundled with 13 jQuery plugins that extend the features and can add more interaction to your site. To get started with Bootstrap’s JavaScript plugins, you don’t need to be an advanced JavaScript developer. In fact, by utilizing Bootstrap Data API, most of the plugins can be triggered without writing a single line of code.
Overview
Bootstrap can be included on your site in two forms, either compiled or raw. In Bootstrap 2.2.2, the uncompressed file is 59KB and the minimized version is only 32KB. All of the Bootstrap plugins are accessible using the included Data API. With this, you don’t need to include a single line of JavaScript to invoke any of the plugin features.
Typically, JavaScript lies in a either a separate file or at the bottom of the page before the closing </body> tag. You can either use the src attribute to link to another file, or you can write the contents of the file between the opening and closing tags:
<!-- To reference another JavaScript file --><scriptsrc="assets/js/javaScript.js"></script><!-- To write JavaScript to the page --><scripttype="text/javaScript">functionjs_alert{alert('Page has loaded');}</script>
Generally, it is best to include all JavaScript calls into a check that ensures that the DOM has been loaded on the page. If you have the JavaScript trying to fire earlier, it may miss elements as the browser parses the page. With jQuery, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access