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

clonescript

v1.0.0

Published

for when speed matters

Downloads

8

Readme

A lightning fast, ultra small javascript template engine

for when speed matters.

cd-img dep-img sz-img

NPM Version lic-img

Documentation

about

Clonescript works directly with the dom to allow you to produece event driven html. Each html element added to your list of used elements is only ever created once. This created element is from then onwards cloned at each call for increased speed.

  • clonescript works directly with the dom
  • less than 1kb in size
  • no regex/unsafe functions
  • about as close to using vanilla js speed as it gets.

Installation

npm

stable release

$ npm install clonescript --save

dev release

git

$ git clone https://github.com/angeal185/clonescript.git

browser

<html>
  <head>
    <meta charset="utf-8">
    <script src="/path/to/clonescript.mjs" type="module"></script>
    <!--- or --->
    <script src="/path/to/clonescript.js"></script>
  </head>
</html>

Setup

The eles const should contain a list of all your used element tags. These will be generated once and then cloned at every call for that element.

  • The tag names txt and default are reserved and cannot be used.
  • Tag names should be in order of usage
  // clonescript.mjs

  // add used elements to create clones of
  const eles = ['div', 'span', 'p', 'input', 'label']

API

/**
 *  @cs.clone(tag, obj, txt)
 *  @param {string} tag ~ html tag
 *  @param {object|string} object ~ element options | string ~ element textContent
 *  @param {string} txt ~ element textContent
 **/

/**
 *  @cs.add(tag, obj, txt)
 *  @param {string} tag ~ html tag
 *  @param {object|string} object ~ element options | string ~ element textContent
 *  @param {string} txt ~ element textContent
 **/

/**
 *  @cs.val() ~ returns html to be appended to page
 **/

element basic

// create a basic element with text

let x = cs.clone('p', 'example plain text').val();

console.log(x)
// <p>example plain text</p>

document.body.append(x)

element id

// create an element with an id

let x = cs.clone('p', {
  id: 'test' // add id
}, 'example id').val();

console.log(x);
// <p id="test">example id</p>

element class

// create an element with an multiple classes

cs.clone('p', {
  class: ['class1', 'class2'], // array of class/es
}, 'example class').val();

console.log(x);
// <p class="class1 class2">example class</p>

element attributes

// create an element with an multiple attributes

cs.clone('input', {
  attr: { // attributes
    type: 'text',
    placeHolder: 'example attributes',
    style: 'color:red;background:black'
  }
}).val()

console.log(x)
// <input type="text" style="color:red;background:black" placeholder="example attributes">

element events


cs.clone('p', {
  fn: { // functions
    onclick: function(){
      console.log('item clicked!');
    },
    onmouseover: function(){
      console.log('item mouseover!');
    }
  }
}, 'example function').val();

console.log(x.click())
// item clicked!
console.log(x.onmouseover());
// item mouseover!

element append


let x = cs.clone('p', {
  append: [
    cs.add('p', 'level 2.1'),
    cs.add('p', 'level 2.2')
  ]
}, 'level 1').val();

console.log(x);
/*
<p>
    level 1
    <p>level 2.1</p>
    <p>level 2.2</p>
</p>
*/

nested text nodes


let x = cs.clone('p', {
  append: [
    cs.add('p', 'basic 1'),
    cs.add('txt','nested text'),
    cs.add('p', 'basic 2'),
    cs.add('txt', 'appended text text')
  ]
}, 'prepended text').val();

console.log(x);
/*
<p>
    prepended text
    <p>basic 1</p>
    nested text
    <p>basic 2</p>
    appended text text
</p>
*/