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

wanilla

v0.0.4

Published

🍦 A 2kB JQuery like Wrapper around Vanilla JavaScript.

Downloads

12

Readme

Video

Watch an introduction of the Include Tag of Wanilla on YouTube.

About

wanilla adds super power to your HTMLElements. Each element wrapped with wanilla will still remain a HTMLElement, but has some cool and easy to use new features.

wanilla also provides a easy way to include other HTML files. You can, for example, easily include your menu or footer as external files.

Import Library

<!-- Get Wanilla from jsDelivr -->
<script src="https://cdn.jsdelivr.net/npm/wanilla/bundle/wanilla.min.js"></script>

<!-- Get Wanilla from UNPKG -->
<script src="https://unpkg.com/wanilla/bundle/wanilla.min.js"></script>
// Get Wanilla from NPM
> npm i wanilla

// include W as default
import W from 'wanilla'

// include the types (if you use typescript)
import { WElement, WInputElement, WBase } from 'wanilla'

Usage

  • If 2 or more parameters are given to W(), it will create a new HTMLElement.
  • If only one parameter is given to W(), it will querySelect the first matching element.
  • To get an array of matching HTMLElements, use W.all().

Simple Example

// use the library after page load
window.addEventListener('load', () => {
  // create <h1 id="title" class="big" >The Title</h1>
  const h1 = W('h1', { id: 'title', class: 'big' }, 'The Title')

  // get the body element
  const body = W('body')

  // append h1 to body
  body.appendChild(h1)
  // same as
  h1.appendTo(body)

  // change color
  h1.css.set('color', 'red')
})

Chaining Example

The script below transforms this:

<div id="container"></div>

Into this:

<div id="container">
  <h2 style="border: 2px solid yellow; padding: 8px 16px;">
    <span style="color: red;">first span</span><span style="color: lightblue;">second span</span>
  </h2>
</div>
// script.js
W('#container')
  .set.HTML('<h2><span>first span</span><span>second span</span></h2>')
  .get.firstChild()
  .css.set('border', '2px yellow solid')
  .css.set('padding', '8px 16px')
  .get.firstChild()
  .css.set('color', 'red')
  .get.nextSibling()
  .css.set('color', 'lightblue')

Include Example

wanilla can easily include other HTML files.

<!-- index.html -->
<body>
  <include-html src="/feature.html" title="some title">placeholder...</include-html>
</body>

<script>
  window.addEventListener('load', () => {
    W.autoInclude()
  })
</script>

<!-- feature.html -->
<div>
  <h2>Some dynamic {TITLE}</h2>
  <p>Hello from feature component</p>
</div>

<!-- after rendering, your index.html page looks like this -->
<body>
  <div>
    <h2>Some dynamic some title</h2>
    <p>Hello from feature component</p>
  </div>
</body>

The feature.html page could even include a CSS file which will automatically be added to the DOM.

<!-- feature.html with its own css file -->
<include-css src="/feature.css"></include-css>

<div id="feature">
  <h2>Some dynamic {TITLE}</h2>
  <p>Hello from feature component</p>
</div>

SSR

You can easily pre-render all your HTML files using the generate-static-site package.

More

There are of course a lot more things you can do, which will be documented soon.

Actually, instead of writing better documentation, I believe, I will rather create a website with some examples. And since this project is part of the fiveserver project, I will probably add the website to wanilla.fiveserver.org.

Maybe check wanilla.fiveserver.org from time to time.