Chapter 7. History, Navigation, and Place with Single-Page Applications

Ajax tends to operate outside the normal web viewing experience. Usually, you click a link to a page, your browser opens another page, you click another link to another page, it's loaded into the browser, and so on. If you wanted to return to the original page, you would click the Back button, navigating back through all the pages visited in the current session. If you wanted to bookmark a page or create a link to the page, you would just copy the URL that's loaded in the browser's navigation bar.

When web applications are created as single-page applications, where all content is managed and loaded on demand via JavaScript, the Back button is useless, as is the concept of a page URL; there is no sense of place when Ajax is used to load and unload page content. As Alex Bosworth wrote in May 2005 (at http://sourcelabs.com/ajb/archives/2005/05/ajax_mistakes.html):

The back button is a great feature of standard web site user interfaces. Unfortunately, the back button doesn't mesh very well with JavaScript. Keeping back button functionality is a major reason not to go with a pure JavaScript web app.

Lack of real web paging is also a big issue for much of a site's advertising. Before Ajax, ad costs were based on the number of page views for a site. Now, if content can be loaded willy-nilly into any page that opens, page views no longer reflect what's really going on with a site.

Search engine optimization also takes a ...

Get Adding Ajax now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.