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

on-load

Package Overview
Dependencies
Maintainers
5
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

on-load

On load/unload events for DOM elements using a MutationObserver

  • 4.0.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
5
Created
Source

on-load

NPM version build status Downloads js-standard-style

On load/unload events for DOM elements using a MutationObserver

usage

var onload = require('on-load')

var div = document.createElement('div')
onload(div, function (el) {
  console.log('in the dom')
}, function (el) {
  console.log('out of the dom')
})

// Will fire the onload
document.body.appendChild(div)

// ... some time later

// Will fire the onunload
document.body.removeChild(div)

API

onload(node, onloadFn, onunloadFn, [caller])

Pass a dom node to onload to have a onloadFn function fire when the dom node is added to the document dom and a onunloadFn fire when the dom node is removed from the document dom. Optionally a caller ID can be set to associate the onload/onunload hooks with a particular instance of of a dom node. This is commonly used when 'componentizing' dom nodes.

license

(c) 2018 Kyle Robinson Young. MIT License

Keywords

FAQs

Package last updated on 29 Mar 2019

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