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

@mass-edge/xpathjs

v0.2.2

Published

XPathJS is a pure JavaScript implementation of XPath 1.0 and DOM Level 3 XPath specifications.

Readme

XPathJS

XPathJS is a pure JavaScript implementation of XPath 1.0 and DOM Level 3 XPath specifications.

Features

  • Works in all major browsers: IE8+, Firefox, Chrome, Safari, Opera
  • Supports XML namespaces!
  • No external dependencies, include just a single .js file
  • Regression tested against hundreds of unit test cases.
  • Works in pages served as both, text/html and application/xhtml+xml content types.
  • Benchmarked against other XPath implementations.

Getting Started

  1. npm install xpathjs then import 'xpathjs' at the top of your js file or Add <script src="https://unpkg.com/@mass-edge/[email protected]/dist/xpathjs.min.js"></script> in the <head> of your HTML document.

  2. Initialize XPathJS:

    // bind XPath methods to document and window objects
    // NOTE: This will overwrite native XPath implementation if it exists
    window.XPathJS.bindDomLevel3XPath();
  3. You can now use XPath expressions to query the DOM:

    var result = document.evaluate(
        '//ul/li/text()', // XPath expression
        document, // context node
        null, // namespace resolver
        XPathResult.ORDERED_NODE_SNAPSHOT_TYPE
    );
    
    // loop through results
    for (var i = 0; i < result.snapshotLength; i++) {
        var node = result.snapshotItem(i);
        alert(node.nodeValue);
    }

Take a look at some working examples to get a better idea of how to use XPathJS.

We would strongly recommend for you to take a look at the CAVEATS document to get a better understanding of XPathJS limitations.

More examples, configuration options, and caveat info coming soon...

Background

So how did XPathJS come to be? Well originally we were looking for an implementation of a cross-browser XForms solution in hopes to alleviate the pain and complexity that comes with creating normal HTML forms. Unfortunately, we found out that there is neither an XForms engine that is fully implemented, nor does it support all browsers. So we thought, ok let's try to build our own! Then we realized that XForms makes extensive use of XPath. And again, we could not find a fully functional cross-browser XPath implementation. Long story short, that's how XPathJS was born.

By releasing XPathJS, we hope to help promote the adoption of open standards in the community.

Development

XPathJS is developed by Andrej Pavlovic. You are more than welcome to contribute by logging issues, sending pull requests, or just giving feedback.