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

elementify

v1.4.2

Published

Ultra lightweight vanilla JS library for DOM and events manipulation, form manipulation and data validation

Downloads

7

Readme

NPM

GitHub release Gzip size Build Status Coverage Status semantic-release Documentation

bitHound Overall Score bitHound Code bitHound Dependencies bitHound Dev Dependencies Known Vulnerabilities

Elementify

Elementify is a vanilla JS library designed to be :

  • powerful but still ultra-lightweight (39,2 KB minified and 8,32KB gzipped)
  • cross-browser (IE9+)
  • focused on DOM manipulation, events management and data validation
  • focused on improving and adding functionnalities to vanilla JS, not shimming or replacing it.
  • UMD pattern for easy integration

Why Elementify ?

Oh no, again an other library to manipulate the DOM ! Really ?

Wait ! Elementify main purpose is not to shim the DOM across browsers. Most of the time, you'll have to rely on vanilla things to do your stuff.

You can see Elementify as the missing link between full vanilla JS and Jquery. Jquery or Mootools (or Underscore in its way) are a replacement to browser's vanilla JS, even for things that are really common nowadays. They are heavy but complete libraries.

On the other side, Elementify is a lightweight creates an abstraction layer to manage events, manipulate the DOM and validate data with ease. You can switch between vanilla and elementified layers at will and choose the best - or the only one - layer able to do your stuff.

I follow three main goals when building Elementify :

  • Have most of the great functionnalities we beloved on other heavy-weighted library for manipulating the DOM
  • Easy event management and easy data validation client-side
  • Syntax and lazyness friendly
  • Focus to stay lightweight and low-memory. Not the fastest but the smallest
  • Have an UMD compliant library for easing integration in other projects

So that's it. Elementify will simply, well, elementify the browser and the DOM.

Installation

As a module

npm install elementify

or

yarn add elementify

Then simply require/import it :

import elementify from 'elementify';
// or for submodule
import {Collection, Element, Q, ready, complete} from 'elementify';

In a browser

Bundle

<script type="text/javascript" src="https://bundle.run/elementify@latest"></script>

JsDelivr

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/elementify@latest"></script>

Unpkg

<script type="text/javascript" src="https://unpkg.com/elementify@latest"></script>

Local install

For browser install, you can simply fetch file dist/objectarray.min.js in this repo or clone it and load it :

<script type="text/javascript" src="myJsFolder/elementify.min.js"></script>

The elementify library will be added to global (window) scope. If you wish to import its exported modules in global scope, simply call

elementify.load()

It will monkey-patch the native Element class by adding the constructor for elementify objects.

Usage

We will assume that the exported modules of elementify are in global running scope.

Create elements

/**
*  All following asserts will lead to the same HtmlElement with a node
*  equal to <div class="div1 div2" id="div">DIV</div>
*/
var div = new Element('<div class="div1 div2" id="div">DIV</div>');
var div = new Element('div', {class: ['div1', 'div2'], id:'div', innerHTML: 'DIV'});
var div = new Element('div').addClass('div1 div2').attr('id', 'div').html('DIV');
var div = Q('+div', {class: ['div1', 'div2'], id:'div', innerHTML: 'DIV'});
var div = Q('+div').addClass('div1 div2').attr('id', 'div').html('DIV');

All properties setters are chainable for easing creation. The Q magic function is quite similar to the famous $ one. It can query the DOM or create elements.

Both Element and Q will check the input and returns the appropriate Element (windowElement, DocumentElement, HtmlElement, FormElement or InputElement) or a Collection of these.

Query DOM

<div class="e1" data-rel="f1"></div>
<div class="e2" data-rel="f2"></div>
<div class="e3" data-rel="f3"></div>
Q('.e1').data('rel') // returns 'f1'
Q('div').attr('class') // returns ['e1', 'e2', 'e3']
Q('[data-rel="f3"').node.className // returns 'e3'

The Q magic function is used to query the DOM and returned the appropriate Element/Collection.

When a method is called on a Collection, Elementify will try to apply it to each member of the Collection and returns an array of result with the same indexing.

To access the ghosted vanilla element, simply call the element or node property of the Elementify object.

Documentation

A nearly complete API reference is available here : https://liqueurdetoile.github.io/Elementify.

Wish I could spare some time to write examples and a manual.

Bugs and features requests

Elementify is test-driven though it did not prevent all issues. Please report here any trouble or features request.

Want to help ?

There is many more to do to implements othe features. Don't mind fork Elementify, tweak it and submit a pull request.