Wait with injecting javascript until the head is loaded