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

@vnphanquang/green-check

v1.0.5

Published

Custom element to render green check badge from the Green Web Foundation

Readme

Green Web Badge as Custom Element

npm badge

Introduction

This library defines an HTML Custom Element to check and display a badge if your site passes the Green Web Check from The Green Web Foundation.

green badge example

See https://github.com/thegreenwebfoundation/admin-portal/issues/234 for the original discussion that led to this library.

1. Installation

Install @vnphanquang/green-check with your package manager of choice (recommended):

pnpm add @vnphanquang/green-check
npm install @vnphanquang/green-check
yarn add @vnphanquang/green-check

[!NOTE] This method is recommended as it allows the green-check module to be part of your dependency tree and build process, making it easier to integrate into framework contexts, track version, and deploy with high availability (you are effectively self-hosting the module).

Alternatively, you may load the module via a CDN by adding to importmap in your html:

<script type="importmap">
	{
		"imports": {
			"@vnphanquang/green-check": "https://cdn.jsdelivr.net/npm/@vnphanquang/green-check/dist/index.js"
		}
	}
</script>

2. Register the Custom Element

Import GreenCheck and register <green-check> using the global customElements, where applicable:

import { GreenCheck } from '@vnphanquang/green-check';

// later where applicable
customElements.define('green-check', GreenCheck);

Optionally, you may find dynamically importing the module to be more efficient depending on your use case:

async function loadGreenCheck() {
	const { GreenCheck } = await import('@vnphanquang/green-check');
	customElements.define('green-check', GreenCheck);
}

// later
loadGreenCheck();

3. Using the Custom Element

Use <green-check> where applicable with the hostname attribute as the host name of your site. If not provided hostname will default to window.location.hostname, i.e current site.

<green-check hostname="www.yourdomain.xyz">
	<img
		src="https://cdn.jsdelivr.net/npm/@vnphanquang/green-check/dist/fallback.svg"
		width="200"
		height="95"
		alt="Fallback blank greencheck badge from The Green Web Foundation, in case JS is not (yet) available"
	/>
</green-check>

Customizing Colors

Colors of the badge can be customized by providing the following CSS custom properties (default values are shown):

<green-check hostname="www.yourdomain.xyz">
	<!-- [...truncated fallback image...] -->
</green-check>

<style>
	green-check {
		/* not passing green check */
		--green-check-fg: #000;
		--green-check-bg: linear-gradient(45deg, #6c6c6c 4%, #dedede 24%, #fff 32%);

		&[green]:not([green='false']) {
			/* passing green check */
			--green-check-fg: #000;
			--green-check-bg: linear-gradient(45deg, #06ff06 4%, #dffcdd 24%, #fff 32%);
		}
	}
</style>

This is helpful to ensure consistency with your site's color scheme or to support dark mode.

Development

Prerequisites

| Dependency | Installation | Description | | ---------- | --------------------------------------- | ------------------------------- | | node | recommended via volta | | | pnpm | follow guide on website | alternative to npm and yarn |

See package.json for preferred versions of node and pnpm. If you have volta installed, simply cd to the project and the correct node version should be installed.

Getting Started

This project is built with Vite. Start by installing dependencies

pnpm install

And run development server

pnpm dev

Versioning & Publishing to NPM

We use changeset to partially automate the process. Typical workflow is as follow:

  1. make changes to codebase,
  2. run pnpm changeset at project root and follow prompt to generate a "changeset" (logging a change),
  3. commit both (1) and (2) into git,
  4. push to main, or (preferably) create PR, review and merge into main (prefer fast-forward merge if possible to keep linear git history),
  5. changesets Github action is triggered on push to main and will create a corresponding "Changesets: Versioning & Publication" PR.
  6. Merging (5) PR will trigger the changesets Github action to run again to build & push a new version to NPM.

Todos

  • [ ] Add tests
  • [ ] Simple playground site