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 🙏

© 2024 – Pkg Stats / Ryan Hefner

define-html

v3.0.0

Published

Define custom element to import in html

Downloads

60

Readme

define-html

Define custom element to import in html

Motivation

When using vanilla HTML + CSS we sometimes want to split HTML on files but do not use powerful and hard solutions

Usage

Add link to preload external html file and define-html script in head:

<head>
    <!-- Other tags here -->
    <link rel="preload" href="app-content.html" as="fetch" crossorigin />
    <script src="https://unpkg.com/define-html" type="module"></script>
</head>

Where app-content.html is:

<template>
    Lorem ipsum
</template>

So later you can use include your template with:

<app-content></app-content>

Features

  • Read attribute values
  • Make conditional elements
  • Full slot support
  • Full style encapsulation
  • Optionally enable shadow root

Docs

Read the docs

Troubleshooting

For the framework to work, you either need to use some static server (e.g. Live Server for VS Code) or use a compiler (see below).

Compiler (optional)

Additionally, you can compile your components inside your pages.

That may be useful when your run your app in production and you want to reduce load time for your users.

Install node or bun and run:

npx --yes define-html

or

bunx --bun define-html

This will create dist folder with the output files. Also, it will copy runtime and replace it in all pages.

Development

This project uses Bun as a build tool and package manager.

License

Apache-2.0