# defunkt/jquery-pjax

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/defunkt-jquery-pjax).**

16,650 stars · 1,930 forks · JavaScript · MIT

## Links

- GitHub: https://github.com/defunkt/jquery-pjax
- Homepage: https://pjax.herokuapp.com
- awesome-repositories: https://awesome-repositories.com/repository/defunkt-jquery-pjax.md

## Description

jquery-pjax is a client-side library that combines Ajax requests with the HTML5 History API to replace page content without triggering a full browser reload. It fetches HTML fragments from the server and updates the browser URL using pushState, preserving the page layout and assets while only swapping a designated container's content. The library emits custom JavaScript events at each stage of the request lifecycle, enabling external handlers to respond to loading, success, and error states.

The project distinguishes itself through its event-driven navigation model and server-side integration. It detects the X-PJAX header on incoming requests, allowing the server to return only the inner container HTML instead of the full page layout. A versioned cache busting mechanism uses a header and meta tag to force a full page reload when server-side assets or layout change. The library also supports form serialization via Ajax, programmatic navigation through a JavaScript API, and container content reload without adding a browser history entry.

The documentation covers server configuration for header detection and fragment delivery, as well as client-side setup for lifecycle event handling and programmatic triggers.

## Tags

### Web Development

- [AJAX Page Loaders](https://awesome-repositories.com/f/web-development/ajax-page-loaders.md) — Replaces page content via Ajax and updates the browser URL using pushState without a full page reload.
- [AJAX Content Swapping](https://awesome-repositories.com/f/web-development/ajax-content-swapping.md) — Fetches HTML fragments via XMLHttpRequest and swaps them into a designated DOM container.
- [Pjax Lifecycle Hooks](https://awesome-repositories.com/f/web-development/backend-development/web-frameworks/routing-request-handling/route-lifecycle-handlers/pjax-lifecycle-hooks.md) — Respond to each stage of a pjax request with custom handlers for loading indicators, error recovery, and content replacement. ([source](https://cdn.jsdelivr.net/gh/defunkt/jquery-pjax@master/README.md))
- [Partial Page Loaders](https://awesome-repositories.com/f/web-development/client-side-frameworks/partial-page-loaders.md) — Provides a client-side library for loading only a container's HTML from the server while preserving layout and assets.
- [AJAX Request Lifecycle Hooks](https://awesome-repositories.com/f/web-development/lifecycle-events/ajax-request-lifecycle-hooks.md) — Emits lifecycle events for loading, success, and error states during pjax requests.
- [Non-Reloading History Updates](https://awesome-repositories.com/f/web-development/navigation-history-providers/non-reloading-history-updates.md) — Updates the browser URL and history using the HTML5 History API without triggering a full page reload.
- [Pjax Header Detection](https://awesome-repositories.com/f/web-development/pjax-header-detection.md) — Detect the X-PJAX header on the server and return only the inner container HTML, skipping the full page layout. ([source](https://cdn.jsdelivr.net/gh/defunkt/jquery-pjax@master/README.md))
- [Programmatic Navigation](https://awesome-repositories.com/f/web-development/programmatic-navigation.md) — Exposes a JavaScript method to trigger pjax requests manually with a URL and container selector.
- [Partial Page Fragments](https://awesome-repositories.com/f/web-development/server-driven-component-rendering/partial-page-fragments.md) — Fetches and swaps a portion of the page based on server responses, skipping full layout rendering.
- [Container Content Reloads](https://awesome-repositories.com/f/web-development/ajax-content-swapping/container-content-reloads.md) — Refetch the current URL via Ajax and replace the container's content without adding a browser history entry. ([source](https://cdn.jsdelivr.net/gh/defunkt/jquery-pjax@master/README.md))
- [Version-Triggered Reloads](https://awesome-repositories.com/f/web-development/asset-versioning/version-triggered-reloads.md) — Set a version header and meta tag so clients perform a hard reload when assets or layout HTML change. ([source](https://cdn.jsdelivr.net/gh/defunkt/jquery-pjax@master/README.md))
- [Ajax Form Submissions](https://awesome-repositories.com/f/web-development/form-data-serializers/ajax-form-submissions.md) — Serializes form data and submits it as an Ajax request, replacing the target container with the response.
- [Asynchronous Form Submissions](https://awesome-repositories.com/f/web-development/form-processing/asynchronous-form-submissions.md) — Send form data as an Ajax request and replace a container's content with the server response without a full page reload. ([source](https://cdn.jsdelivr.net/gh/defunkt/jquery-pjax@master/README.md))

### Software Engineering & Architecture

- [Ajax Request Lifecycle Hooks](https://awesome-repositories.com/f/software-engineering-architecture/lifecycle-event-hooks/ajax-request-lifecycle-hooks.md) — Emits custom JavaScript events at each stage of the request lifecycle for external handler attachment.

### User Interface & Experience

- [Pjax Navigation Triggers](https://awesome-repositories.com/f/user-interface-experience/programmatic-triggers/pjax-navigation-triggers.md) — Initiate a pjax request from custom JavaScript code by specifying the URL and target container manually. ([source](https://cdn.jsdelivr.net/gh/defunkt/jquery-pjax@master/README.md))
- [Server-Driven Fragment Replacement](https://awesome-repositories.com/f/user-interface-experience/server-driven-fragment-replacement.md) — The server detects the X-PJAX header and returns only the inner container HTML instead of the full layout.

### DevOps & Infrastructure

- [Version-Triggered Full Reloads](https://awesome-repositories.com/f/devops-infrastructure/asset-caching-strategies/cache-busting/version-triggered-full-reloads.md) — Uses a version header and meta tag to force a full page reload when the server-side layout or assets change.
