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

css-observe

v0.0.61

Published

Fire a custom event whenever an element matching a specified selector is added.

Downloads

124

Readme

Published on webcomponents.org

Actions Status

css-observe

css-observe is a "web component as a service" that specializes in watching for DOM elements matching a CSS selector appearing within the same Shadow DOM realm (or within a specified "closest" selector). When such an element is spotted, css observe can perform up to four distinct actions:

  1. Fire an event.
  2. Perform a DTR transform on the newly discovered element ("target").
  3. Perform a DTR transform on the host's shadow DOM (or document when outside any shadow DOM).
  4. Perform an action contained within a script tag contained nearby (preferably before).

API Reference

<div>
    <script id=my-script nomodule be-exporting>
        export const action = (target) => {
            target.setAttribute('I am here', '');
        }
    </script>
    <css-observe observe selector="div[test]" data-name="Clive" script-ref=my-script  options='{
        "targetTransform": {
            "span": "dataset.name"
        },
        "hostTransform":{
            "section": [{},{},{},"<span>found it</span>"]
        }
    }'>
    </css-observe>

    <div test>
        I am here, <span></span>
    </div>
    <section></section>
</div>

Another attribute / property, within-closest/withinClosest, restricts matches to those within the closest ancestry of the css-observe element matching the within-closest value.

css-observe will fire event: latest-match-changed, and the newly added element can be obtained from event.detail.value.

It will only observe the selector within the same Shadow DOM realm where the element is placed. If the element is placed outside any ShadowDOM, it will observe the selector only outside any ShadowDOM.

Implementation

Based off of an idea found here. I agree: How cool is that?

Viewing Your Element

$ npm install
$ npm run serve

Running Tests

$ npm run test