Book Image

JavaScript at Scale

By : Adam Boduch
Book Image

JavaScript at Scale

By: Adam Boduch

Overview of this book

Table of Contents (17 chapters)
JavaScript at Scale
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Approaches to routing


There are two approaches to routing in JavaScript. The first is using hash-based URIs. These are the URIs that begin with the # character and this is the more popular approach. The other less popular approach is to use the history API of the browser to generate more traditional URIs the web population is used to. This technique is more involved, and has only recently gained enough browser support to make it viable.

Hash URIs

The hash portion of the URI was originally intended to point to a specific location in the document. So the browser would look at everything to the left of the # character, and send this information to the backend, asking for some page content. Only when the page arrived and was rendered did the right side of the # character become relevant. This is when the browser used the hash portion of the URI to find the locally relevant spot within the page.

Today, the hash portion of the URI is used differently. It's still used to avoid passing irrelevant data...