Faster and simplified version of on-load without dom diffing support
Last updated a year ago by bret .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install fast-on-load 
SYNC missed versions from official npm registry.


Build Status

Faster and simplified version of on-load without dom diffing support.


const onload = require('fast-on-load')

onload(domElement, function () {
  console.log('element was mounted')
}, function () {
  console.log('element was unmounted')

Uses a MutationObserver and a generated class together with getElementsByClassName() to find DOM nodes that on-load is tracking, which performs much faster (around 1000x in our machines) on bigger DOM trees that the tree traversal algo on-load uses.


const node = onload(node, [onload], [onunload])

Watch node, optionally passing onload and onunload handler. Returns the node itself.

onload.delete(node, [onload], [onunload])

Pass in references to the onload and onunload functions and the node they are attached to to remove them from the function set that get run on load and unload. Pass undefined for onload if you only attached and onunload function.

onload = onload.bind(dom.window)

To run in non-dom context, such as jsdom, call onload with desired window context.


npm install fast-on-load



Current Tags

  • 1.2.0                                ...           latest (a year ago)

5 Versions

  • 1.2.0                                ...           a year ago
  • 1.1.1                                ...           a year ago
  • 1.1.0                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Today 0
This Week 0
This Month 17
Last Day 0
Last Week 5
Last Month 32
Dependencies (0)
Dev Dependencies (6)
Dependents (4)

Copyright 2014 - 2017 © |