DOM event listener for the browser and node.js