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

dom-q

v0.4.0

Published

DOM batching library

Downloads

25

Readme

dom-q

dom-q is a simple queue for batch execution of DOM mutation operations. Each queue instance exposes an interface to standard DOM operations (i.e. setAttribute, appendChild, insertBefore etc). Behind the scenes, sequences of operations are recorded and batch-applied at a later time, scheduled with requestAnimationFrame() where available.

Installation

npm/browserify

Get it:

npm install --save dom-q

Require it:

var domq = require('dom-q');

UMD

Copy and paste either build/dom-q.js or build/dom-q.min.js into your project.

API

var q = domq.batch()

Create a new queue that batches executes DOM operations using requestAnimationFrame().

See below for the available queue operations.

var q = domq.immediate()

Create a new "queue" that exposes the same batching API as domq.batch(), but instead applies operations synchronously.

See below for the available queue operations.

Attributes

q.setAttribute(el, attribute, value)

q.removeAttribute(el, attribute)

Style

q.style(el, attribute, value)

q.style(el, attributes)

q.removeStyle(el, attribute)

Classes

q.addClass(el, classes)

classes may contain multiple, space-separated class names.

q.removeClass(el, classes)

classes may contain multiple, space-separated class names.

q.toggleClass(el, classes)

classes may contain multiple, space-separated class names.

Native DOM interface

q.appendChild(parentNode, childNode)

q.insertBefore(parentNode, newNode, referenceNode)

q.insertAfter(parentNode, newNode, referenceAfter)

q.removeChild(parentNode, childNode)

q.replaceChild(parentNode, newChild, oldChild)

Sugared DOM interface

q.before(referenceNode, newNode)

Convenience method; equivalent to q.insertBefore(referenceNode.parentNode, newNode, referenceNode).

q.after(referenceNode, newNode)

Convenience method; equivalent to q.insertAfter(referenceNode.parentNode, newNode, referenceNode).

q.replace(childNode, replacementNode)

Convenience method; equivalent to q.replaceChild(childNode.parentNode, replacementNode, childNode).

q.remove(childNode)

Convenience method; equivalent to q.removeChild(childNode.parentNode, childNode).

q.append(el, content)

Append content to el. Content can be a DOM node, DocumentFragment, HTML/text string, or an array of the above.

q.clear(el)

Remove all child nodes of el.

q.content(el, htmlContent)

Set content of el to htmlContent. Equivalent to clear followed by append, and as such accepts the same argument types.

Text

q.text(el, textContent)

Other

q.call(fn)

Insert an arbitrary function into the queue; will be called in the course of normal queue processing.

q.afterFlush(fn)

Insert an arbitrary function into the queue; will be called after the next batch of operations has been completely processed. For immediate queues invocation is immediate.

Copyright & License

© 2014 Jason Frame [ @jaz303 / [email protected] ]

Released under the ISC license.