DOM injection: wait until head element is present; insertBefore instead of append