Book Image

Mastering KnockoutJS

By : Timothy Moran
Book Image

Mastering KnockoutJS

By: Timothy Moran

Overview of this book

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

Single Page Application (SPA) routing


A big part of the appeal of Knockout (or any MV* framework) is that its template engine allows us to rerender parts of the page without the need to talk to the server. Being able to make incremental page updates on the client side means less latency, giving the application a much snappier feel. SPAs take this concept to the next level by letting the JavaScript client control navigation between pages. When the browser navigates, it has to rerender the whole page, which means reloading the JavaScript, HTML, CSS, and everything. When JavaScript navigates, it just has to change part of the HTML, which ends up being much faster in most cases.

Knockout can provide this virtual page-changing functionality relatively easily, but an important component of SPAs is that page changes still update the URL. This helps the user check whether a change has occurred, but more importantly, it means that if the user refreshes the page or shares the link, the application...