DumDum is a condtional JavaScript executor, or a router if you will. Routes are executed based on class names on the body element. DumDum has no package dependencies, but relies on MutationObservers. Although it provides a light replacement for cases where MutationObservers are not availiable.
npm install dumdum-js --save
CommonJs:
var DumDum = require('dumdum-js')
ES6:
import DumDum from 'dumdum-js'
Using it in your javascript:
new DumDum({
common: function() {
// Generic JS here.
},
home: function() {
// JS for pages containing the 'home' class
},
nav_ready: function() {
// Will be executed as soon as the 'nav-ready' class is added to the body.
}
})
This will enable DumDum to watch for changes to your body
element.
If you need to watch for changes on different element you can pass it as the second argument:
new DumDum({
...
}, document.querySelector('#awesome-div'))
MIT license