write single-page apps with a single callback to handle pushState events
Given some html with elements
foo foO fOo fOO Foo FoO FOo FOObarbar baR bAr bAR Bar BaR BAr BARbazbaz baZ bAz bAZ Baz BaZ BAz BAZfoo
Now turn each of the divs into pages with their own routes. Note that this module doesn't update the link callbacks for you. You'll need to handle that for yourself.
var divs =foo: documentbar: documentbaz: document;var singlePage = ;var showPage =;var links = document;for var i = 0; i < linkslength; i++linksi;
You'll need to have a server that will serve up the same static content for each of the pushState routes. Something like this will work:
var http = ;var ecstatic = __dirname;var server = http;server;
Now when you go to
http://localhost:5000 and click around, you'll see
/baz in the address bar when you click links, even though you're
not reloading the page.
var singlePage =
cb(href, page) at the start and whenever the page navigation changes so
you can update the page contents accordingly.
page.scrollY are saved
for every unique
href so that you can jump back to the same scroll position
that the user left off at.
href, firing the callback passed to singlePage.
Update the location href in the address bar without firing any callbacks.
npm install single-page
Use browserify do bundle this module into your application.