pjax is a jQuery library that takes regular old page navigation links and turns them into triggers for fast and unobtrusive ajax content loading. Thanks to modern browser features, page URLs, titles and browser history are all updated as usual, even though the pages are not actually reloaded. Like magic!
Before the History API, the only way to keep history state and provide permalinks for dynamically loaded content was by using a hack that involved URL fragments, which is a common technique that has recieved some criticism recently.
How it works
With pjax, you define a number of links that you use to navigate between pages on your site (can be your whole navigation menu, or just a particular set of links), as well as a main content area where the actual content part of the pages live. With this information, pjax loads the requested page content from the server and inserts it in the container whenever one of the links is clicked. Since only the content part of the page has to be reloaded, and not the whole page, the result is faster page loads that require less resources, both on the server and the client side. (The difference won't always be that big though – it depends on how complex the side content is, among other things.)
In order for the web server to know that it's dealing with a pjax request, it is handed a special HTTP header. When the server application running the site sees that header, it knows to skip rendering everything on the page apart from the main content area. This means that in order for pjax to be a real performance win, the server application needs to support this. Thankfully, this is not a big hurdle. The pjax page mentions solutions for Rails, Django and ASP.NET – which is helpful, but not for the Drupal project I'm currently working on.
pjax for Drupal
Luckily, implementing pjax for Drupal is not that hard. The project work turned out to be kind of generic, and with just a little extra effort, pjax for Drupal was born! As an example, I've implemented pjax on the blog category navigation on the blog overview page on this site. When you switch between the categories, you should see that the content switches quicker than when you click on links in the main menu.