Mimics the Wordpress functions do_action and add_action in JavaScript