Nobody Prefers Margarine

    dumdum-js

    0.3.0 • Public • Published

    Dumdum Js

    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 version NPM downloads Build status Test coverage

    Installation

    npm install dumdum-js --save

    Usage

    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'))

    License

    MIT license

    Keywords

    none

    Install

    npm i dumdum-js

    DownloadsWeekly Downloads

    0

    Version

    0.3.0

    License

    MIT

    Unpacked Size

    8.51 kB

    Total Files

    6

    Last publish

    Collaborators

    • tormorten