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 🙏

© 2025 – Pkg Stats / Ryan Hefner

libxslt-wasm

v0.0.14

Published

JavaScript bindings for libxslt compiled to WebAssembly

Readme

libxslt-wasm

License NPM version

A WebAssembly port of libxslt (XSLT 1.0) and libxml2 for Node.js using Emscripten.

If you're looking for a well-maintained JavaScript XML/XSLT library, you should consider using one of the following libraries instead:

XML:

  • htmlparser2 (and its complements cheerio, domutils, etc.) - Fast & forgiving HTML/XML parser
  • fast-xml-parser - Validate XML, Parse XML, Build XML without C/C++ based libraries
  • @xmldom/xmldom - A pure JavaScript W3C standard-based (XML DOM Level 2 Core) DOMParser and XMLSerializer module
  • libxml2-wasm - WebAssembly-based libxml2 JavaScript wrapper

XSLT:

Installation

npm install libxslt-wasm # npm
yarn add libxslt-wasm    # yarn
pnpm add libxslt-wasm    # pnpm

Usage

This library is fairly niche and is not intended to be a drop-in replacement for other libraries. Its intended use cases are:

  • Applying XSLT to XML documents and NOT for general-purpose XML parsing or querying (e.g. XPath, DOM, etc.)
  • Applying XSLT 1.0 and not XSLT 2.0/3.0
  • Replicating the behavior of browsers (specifically WebKit and Blink which use libxslt)
  • Parsing an XSLT stylesheet that includes a number of external files (via xsl:include, xsl:import) that would be infeasible to download beforehand with relative URLs
  • Capable of enabling EXSLT modules and their functions

i.e. if all the aforementioned libraries can't transform your XML document but the xsltproc CLI tool can do so easily without any issues, you might consider using this library.

To view a demo of the library in action, check out the website libxslt-wasm-demo.pages.dev (source code).

import { writeFile } from "fs/promises";

import { XmlDocument, XsltStylesheet } from "libxslt-wasm";
import { registerModule } from "libxslt-wasm/exslt";

registerModule("common"); // Register EXSLT common module

using doc: XmlDocument = await XmlDocument.fromUrl(
  "https://dailymed.nlm.nih.gov/dailymed/services/v2/spls/2b4255a7-f9f5-4235-8dbb-b0f03acbd624.xml",
);
// Equivalent to `await XsltStylesheet.fromUrl("https://www.accessdata.fda.gov/spl/stylesheet/spl.xsl");`
using xsltStylesheet: XsltStylesheet | null =
  await XsltStylesheet.fromEmbeddedXmlDocument(doc); // From <?xml-stylesheet?> processing instruction

if (xsltStylesheet === null) {
  throw new Error("Invalid XSLT stylesheet");
}

using result: XmlDocument = await xsltStylesheet.apply(doc, {
  // Set <xsl:param> values
  "show-data": "/..",
});

await writeFile("output.xml", result.toString({ format: true })); // As XML
await writeFile("output.html", result.toHtmlString({ format: true })); // As HTML

However, there are some caveats:

  • Top-level await is required (see src/internal/module.ts) which is only avaliable in Node.js 14.8+ and in ECMAScript modules (ESM)
  • JavaScript Promise Integration (JSPI) must be enabled on Node.js via --experimental-wasm-jspi (v22+) or --experiment-wasm-stack-switching (v19.2+).
    • Furthermore, since this library operates by using JSPI to intercept any HTTP requests with Node.js fetch (v18+), some functions in this library return a Promise
  • Since this library is a WebAssembly port of libxslt, it does not support the XSLT 2.0/3.0 or XQuery specifications
  • To interact with the compiled WebAssembly memory, wrapper classes are provided (XmlDocument, XsltStylesheet, etc.) that must be disposed of after use (either declaratively with the using statement or imperatively with the .close() method) to prevent memory leaks

License

This project is licensed under the MIT License - see the LICENSE file for details. It makes use of the following libraries: