index.js
/**
 * Since browsers (JavaScript) does not provide any API to handle Element's append event, we have to
 * use a hacky-tricky solutions for this. There are two "clean" methods discovered for now of how
 * append event can be implemented. Of course, there is a lot more methods of solution, but these
 * ones are fully modular and does not have side effects.
 * Chose one that fits your needs at best.
 * @author ZitRo (https://github.com/ZitRos)
 * @see http://goo.gl/Ai2bkw (StackOverflow original question)
 * @see https://github.com/ZitRos/dom-onceAppended (Home repository)
 */
Since browsers (JavaScript) does not provide any API to handle Element's append event, we have to
use a hacky-tricky solutions for this. There are two "clean" methods discovered for now of how
append event can be implemented. Of course, there is a lot more methods of solution, but these
ones are fully modular and does not have side effects.
Chose one that fits your needs at best.
Since browsers ( JavaScript ) does not provide any API to handle Element ' s append event we have to use a hacky - tricky solutions for this . There are two " clean " methods discovered for now of how append event can be implemented . Of course there is a lot more methods of solution but these ones are fully modular and does not have side effects . Chose one that fits your needs at best .
function useDeprecatedMethod (element, callback) {
    let listener;
    return element.addEventListener(`DOMNodeInserted`, listener = (ev) => {
        if (ev.path.length > 1 && ev.path[ev.length - 2] instanceof Document) {
            element.removeEventListener(`DOMNodeInserted`, listener);
            callback();
        }
    }, false);
}
function useDeprecatedMethod ( element , callback ) { let listener ; return element . addEventListener ( ` ` , listener = ( ev ) => { if ( ev . path . length > 1 && ev . path [ ev . length - 2 ] instanceof Document ) { element . removeEventListener ( ` ` , listener ) ; callback ( ) ; } } , false ) ; }
Since browsers (JavaScript) does not provide any API to handle Element's append event, we have to
 use a hacky-tricky solutions for this.
Since browsers ( JavaScript ) does not provide any API to handle Element ' s append event we have to use a hacky - tricky solutions for this .