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

eleventy-plugin-transformdom

v1.0.1

Published

An eleventy plugin to modify the DOM when outputting HTML

Readme

DOM Transforming plugin

Banner image

Process & change the generated HTML output of your Eleventy site.

Configure the plugin with your CSS selectors and transform functions, then the plugin will run them on each HTML file generated by Eleventy.

Some of the things you could use it to do include:


Like this project? Buy me a coffee via PayPal or ko-fi


Getting started

Install the plugin

In your project directory run:

# Using npm
npm install eleventy-plugin-transformdom --save-dev

# Or using yarn
yarn add eleventy-plugin-transformdom --dev

Then update your project's .eleventy.js to use the plugin:

const transformDomPlugin = require('eleventy-plugin-transformdom');

module.exports = function (eleventyConfig) {
  eleventyConfig.addPlugin(transformDomPlugin, [
    {
      selector: 'img',
      transform: ({ elements }) => {
        elements.forEach((img) => {
          img.setAttribute('loading', 'lazy');
        });
      },
    },
  ]);
};

☝️ The example above shows a Transform Item that finds all the images in your HTML and adds loading="lazy" to the markup. Read on to learn how to customise your own transforms.

Write your Transform Items

The plugin takes a Transform Item array as configuration.

A Transform Item is an Object that contains two keys; selector & transform

Each Transform Item will be run in order. This means you can write a Transform Item that modifies the DOM, then the next Transform Item can further modify the resulting DOM, and so on.

selector

The "selector" is a CSS selector (string).

Multiple selectors may be separated with commas.

transform

The "transform" is a function ((args) => void) that will be run on the generated HTML.

The function will be passed an Object as argument. The args Object has the following entries:

| Key | Type | Description | |---|---|---| | elements | Element[] | An array of elements in the DOM matching the provided selector | | window | DOMWindow | The window of the generated HTML | | document | Document | The window.document of the generated HTML | | inputPath | string | The source file path from which Eleventy is generating the HTML | | outputPath | string | The output path/filename of the HTML file being generated | | inputDir | string | The source directory from which Eleventy is building the site (see the Eleventy docs) | | outputDir | string | The directory inside which the finished templates will be written to by Eleventy (see the Eleventy docs) |

Note: async transform functions are supported, however they will be run in sequence to prevent race conditions.

Contributing

This project welcomes suggestions and Pull Requests!

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgments

  • The wonderfully supportive team at Future Friendly
  • Everyone who has contributed to the 11ty and JSDOM projects, without whom this plugin wouldn't run

Like this project? Buy me a coffee via PayPal or ko-fi