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

bodybuilderjs

v1.0.301

Published

Build Websites through js, Dynamically

Readme

bodyBuilderJS

An Easier way of Coding without JSX and minimizing the amount of Javascript you write this module can be used in a static html site as well as node js environments ** Client side ONLY

purpose

The purpose of this library is to mimimize the amount of code you have to write in order to dynamically change/create HTML elements

before bodyBuilder

let main = document.querySelector("div.main");
main.style.color = "red";
main.style.fontWeight = "bold";
main.style.textDecoration = "underline";
main.addEventListener("click", () => {
  //some code to do more things!
  main.style.color = "blue";
  main.innerHTML = "reeeee so much things!!";
  let box = document.createElement("div");
  box.style.color = "green";
  box.appendChild(document.createTextNode("im not blue da be daa"));
  main.appendChild(box);
});

After:

let main = l("div.main");
main.setattr({
  style: {
    color:"red",
    fontWeight:"bold",
    textDecoration:"underline"
  }
  on:{
     click() {
        //some code to do more things!
        main.setattr({
          style:{
            color:"blue",
            
          }
        });
        main.inHTML = "reeeee so much things!!";
        let box = l.CE("div");
        box.setattr({
          style:{
            color:"green"
          }
        })
        box.apCh(
          "im not blue da be daa"
          
        );
        main.apCh(box,"some extra text to show how efficient bodyBuilderJS is!");
     }
  }
});

as you can see there, you can minimize so many functions and extra commands with BodyBuilderJS!

DOCS

l(query):

| main command for bodyBuilder | a shortcut for using document.querySelector(foo) | the argument 'query' only accepts strings

l.CE(elename)

| main command for creating Elements | shortcut for document.createElement(foo) | argument elename only accepts strings

both of these commands add special attributes to elements even not made by bodybuilder

some of these attributes are commands are:

ele.apCh(...children)

|| secondary command after creating element or selecting element from document || apch is short for document.appendChild || apch accepts

  • More than 1 argument of
  • documentElement
  • string
  • functions -> string/documentElement/number
  • numbers
  • object
    • note: Objects are special in these cases because they represent elements in BodyBuilder,
    • Example
        element.apCh(
          {
            div:[/*other things that Apch accepts*/],
            style:{},
            on:{},
            class:{}
          }
        );
      element name has to go first because without this BodyBuilder will throw an error due to there not being a viable documentElement to process this. the rest can go in any order as you like.

ele.setattr(obj);

|| almost like Apch when using object except element name is not required and will not thow an error when not passing an element name || setattr obviously accepts object, WILL NOT ACCEPT strings numbers or functions || however this will accept strings inside of an Object

Structuring Objects within apCh and setattr.

so lets start of with a basic Object within apch:

let body = l("body");
body.apCh({
  /*empty element WILL CAUSE AN ERROR!!*/
}/*other elements you might want to add*/)

passing objects through this function are dynamic, which means you can pass as many keys there are chickens in the world (heavily advised not to do that). so lets just focus on the object and see some basic stuff you can do with it.

{
  elementname:[],
  class:[],
  style:{},
  on:{},
}

these properties that i have passed into this object have special properties that are given to them, as you might've figured by the class and style attributes, so heres some basic rules to this

  • Elementname is the tag Name: e.g. passing div will create <div></div> when outputted THIS IS REQUIRED
    • on value side of this object, there is a list, this is sort of an InnerHTML/ChildList zone, so passing "hello" through this list would produce <div>hello</div> of course this is an extension of the apCh function which means you can put as many elements as you want to it, THERE IS NO LIMIT,
  • class, of course is the classList of the Element, this attribute accepts Classes in list form or string form, in string form classes are seperated by spaces, just like how you'd write it in HTML. Again you can pass as many as you want no limit. OPTIONAL
  • Style, unlike how youd write it in HTML, cannot accept Strings or lists, only Objects, because this is kind of your own little element specific Ruleset. OPTIONAL
    • so you can pass any property through this object just like how you would when writing CSS (you can pass CSS vars through it too!)
    • so passing a couple properties like:
    {
      div:["hello"],
      class:[],
      style:{
        color:"red",
        textDecoration:"underline wavy white",
        "-webkit-text-decoration":"underline wavy white",
        background:"black"
      }
    }
    would produce:
    <div class="" style="color:red;text-decoration:underline wavy white;-webkit-text-decoration:underline wavy white;background:black;">
      hello
    </div>
  • On, the most helpful attribute so far, its basically element.addEventListener() made for Objects. again Optional
    • the On attribute can only accept Objects due to the affect that the eventlisteners need to be able to listen to a certain event.
    • think of on as a part of of an attribute that you add to an element in HTML, like "onclick" or "onplay",
    • an example of this would be
    {
      div:["hello"],
      class:[],
      style:{
        color:"red",
        textDecoration:"underline wavy white",
        "-webkit-text-decoration":"underline wavy white",
        background:"black"
      },
      on:{
        click:(event) => {/*do something*/}/*ES8 function*/
        /*ES6/5 and later...*/
        click:function (event) {/*do something*/}
      }
    }
    • note: when you use this in the object, these will not be shown in the HTML structure as they are using Event listeners.
  • Use this structure with setattr but do not pass the element name because you only changing the attribute structure
  • final attribute(s), other attributes that are not class,on,style or elementname will be added as data to the Element, eg passing role:"button" would produce <button role="button"></button> Well this is it.. you're ready to code with BodyBuilderJS, Bye!!