Dom watchdog in plain javascript