# Pjax [![Build Status](http://img.shields.io/travis/MoOx/pjax.svg)](https://travis-ci.org/MoOx/pjax) [![browser support](https://ci.testling.com/MoOx/pjax.png)](https://ci.testling.com/MoOx/pjax) > Easily enable fast Ajax navigation on any website (using pushState + xhr) Pjax is ~~a jQuery plugin~~ **a standalone JavaScript module** that uses ajax (XmlHttpRequest) and [pushState()](https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history) to deliver a fast browsing experience. _It allow you to completely transform user experience of standard websites (server side generated or static ones) to make them feel they browse an app. Especially for user that have low bandwidth connection._ **No more full page reload. No more lots of HTTP request.** # Note: current master is WIP. Checkout [v0.1.4](https://github.com/MoOx/pjax/tree/a17a6b90bebefd8f5209e6a6f7d8c5d59296232a) for latest "stable" (no tests so kind of funny to call that stable). ## Demo [You can see this running on my website](http://moox.io), with sexy CSS animations when switching pages. ## How Pjax works Pjax loads page using ajax & updates the browser's current url using pushState without reloading your page's layout or any resources (js, css), giving a fast page load. _But under the hood, it's just ONE http request with a pushState() call._ Obviously, for [browsers that don't support pushState()](http://caniuse.com/#search=pushstate) Pjax fully degrades (yeah, it doesn't do anything at all). It simply works with all permalinks & can update all parts of the page you want (including html metas, title, navigation state). - It's not limited to one container, like jQuery-Pjax is, - It fully support browser history (back & forward buttons), - It **will** support keyboard browsing (@todo), - Automatically fallback to classic navigation for externals pages (thanks to Capitain Obvious help), - Automatically fallback to classic navigation for internals pages that will not have the appropriated DOM tree, - You can add pretty cool CSS transitions (animations) very easily. - It's around 3kb (minified & gzipped). ### Under the hood - It listen to every clicks on links _you want_ (by default all of them), - When an internal link is clicked, Pjax grabs HTML from your server via ajax, - Pjax render pages DOM tree (without loading any resources - images, css, js...) - It check if all defined parts can be replaced: - if page doesn't suit requirement, classic navigation used, - if page suits requirement, Pjax does all defined DOM replacements - Then, it updates the browser's current url using pushState ## Overview Pjax is fully automatic. You won't need to setup anything on the existing HTML. You just need to designate some elements on your page that will be replaced when you navigate your site. Consider the following page. ```html
Sha blah blah.
``` We want Pjax to grab the url `/blah` then replace `.my-Content` with whatever it gets back. Oh and the `