Book Image

KNOCKOUTJS BLUEPRINTS

By : Carlo Russo
Book Image

KNOCKOUTJS BLUEPRINTS

By: Carlo Russo

Overview of this book

Table of Contents (12 chapters)
KnockoutJS Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Modularizing with the component binding handler


In this section, we are going to discuss two different concepts:

  • AMD and RequireJS

  • KnockoutJS binding handler called component

The reason we are going to look at them together is because the best way to use the second one is with the help of the first one.

AMD and RequireJS

Asynchronous Module Definition (AMD) is a way to modularize JavaScript; you can get a good overview of what AMD is and why it is a good idea to use it at this URL: http://requirejs.org/docs/whyamd.html.

Before the use of AMD, all HTML pages were full of script tags to import all the scripts used. You have seen this behavior in the previous chapter, when we put five script tags into each HTML page.

One of the goals of AMD is to improve the separation of JavaScript and HTML; we get this because we put only one script tag in the HTML file, representing the main entrance to our client-side application. Inside this entrance file we put all the logic to load the other components, with...