Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dom-batch

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dom-batch

Eliminates layout thrashing by batching DOM read/write interactions

  • 0.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

dom-batch Build Status

Eliminates layout thrashing by batching DOM read/write interactions.

var dom = new DomBatch();

dom.read(function() {
  console.log('<DOM Read>');
});

dom.write(function() {
  console.log('<DOM Write>');
});

dom.read(function() {
  console.log('<DOM Read>');
});

dom.write(function() {
  console.log('<DOM Write>');
});

// Output:

<DOM Read>
<DOM Read>
<DOM Write>
<DOM Write>

API

DomBatch#read(callback[, context])

Schedules a task for the 'read' queue.

dom.read(function() {
  var width = element.clientWidth;
});

DomBatch#write(callback[, context])

Schedules a task for the 'write' queue.

dom.write(function() {
  element.style.width = width + 'px';
});

DomBatch#clearRead(callback)

Removes a task from the 'read' queue.

var fn = function(){};

dom.read(fn);
dom.clearRead(fn);

DomBatch#clearWrite(callback)

Removes a task from the 'write' queue.

var fn = function(){};

dom.write(fn);
dom.clearWrite(fn);

Tests

With PhantomJS
$ npm install
$ npm test
Without PhantomJS
$ node_modules/.bin/buster-static

...then visit http://localhost:8282/ in browser

Author

  • Wilson Page - @wilsonpage

Contributors

FAQs

Package last updated on 26 Aug 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc