npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@softono/pjax

v1.1.2

Published

Lightweight and powerful PJAX SPA library for Laravel, CodeIgniter, and PHP applications.

Readme

Easy and Powerful PJAX : Single Page Application (SPA) Library

pjax.js is a lightweight and efficient library for implementing Single Page Applications (SPA) in Laravel, CodeIgniter, or any PHP-based project. It enables partial page loads and seamless navigation without full-page reloads, enhancing user experience and performance.

Features

  • Partial Page Loading: Load only the required content via AJAX.
  • Session Storage Caching: Cache pages for faster navigation.
  • Dynamic Menu Updates: Automatically update active menu items based on the current URL.
  • Customizable: Easily integrate with Laravel, CodeIgniter, or other PHP frameworks.
  • Scroll Management: Control scroll behavior during navigation.
  • Error Handling: Graceful handling of unauthorized or error responses.

Installation

  1. Clone or download the repository.
  2. Include pjax.js in your project:
<script src="path/to/pjax.js"></script>
  1. Ensure you have jQuery included in your project as pjax.js depends on it.
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

Usage

HTML Setup

Wrap your main content in a container with the ID main-container:

<div id="main-container" data-layout="main">
  <div id="main-content" data-title="">
    <!-- Main content goes here -->
    <div></div>
  </div>
</div>

Add the pjax class to your links to enable PJAX navigation:

<a href="/example" class="pjax">Example Link</a>

JavaScript Initialization

Initialize pjax.js when the DOM is ready. You can also define hooks to run custom code during navigation:

$(document).ready(function() {
  // Hook executed when a PJAX link is clicked
  pjax.onLinkClick = function(target) {
    // e.g., Show a custom loader or update UI
    $(target).addClass('active').siblings().removeClass('active');
  };

  // Hook executed after page content is updated
  pjax.onPageLoaded = function(url) {
    // e.g., Send pageview to analytics
    console.log("Successfully loaded: " + url);
  };

  pjax.init();
});

Server-Side Integration

Ensure your server can handle partial requests by checking for the partial query parameter. For example, in PHP:

if (isset($_GET['partial']) && isset($_GET['layout']) && $_GET['layout'] == 'main') {
    include 'partials/content.php';
}

Rules for PJAX SPA Functionality

  • Each link (<a> tag) where you want to apply PJAX SPA functionality must include the pjax class.
  • The data-pjax-cache attribute is optional and should only be used for static pages that need to be cached in the browser.

Caching

To enable caching for specific links, add the data-pjax-cache attribute:

<a href="/example" class="pjax" data-pjax-cache="true">Cached Link</a>

Scroll Behavior

Control scroll behavior by setting the data-pjax-scroll attribute:

<a href="/example" class="pjax" data-pjax-scroll="false">No Scroll</a>

Run JavaScript Code After PJAX Updates

HTML Setup

Add the following script to the header of your HTML file:

<script>
  var documentReadyFunctions = [];
  function documentReady(fn) {
    documentReadyFunctions.push(fn);
  }
</script>

JavaScript Execution After Content Update

To ensure JavaScript code runs after PJAX updates, include the following function call at the bottom of your view:

documentReady(function () {
  //add your code here
});

This function will execute all registered documentReady functions after the HTML content is updated. this is alternative to jquery $(document).ready()

API Documentation

pjax Object

Hooks

  • pjax.onLinkClick(target)
    • Function executed when a PJAX-enabled link is clicked.
  • pjax.onPageLoaded(url)
    • Function executed after PJAX successfully loads and updates the page content.

Methods

  • pjax.init()
    • Initialize PJAX functionality.
  • pjax.loadPage(url, cache, scroll)
    • Load page content via AJAX.
  • pjax.updateContent(html)
    • Update the main container with new content.
  • pjax.updateActiveMenuByUrl()
    • Update active menu items based on the current URL.
  • pjax.routeLinks()
    • Set up click handlers for PJAX-enabled links.

Contributing

Contributions are welcome! Feel free to submit issues or pull requests to improve this library.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

Special thanks to the open-source community for inspiration and support.