Fixes JavaScript error

(which was caused by not passing the required second argument to `insertBefore`)