Fix worker initialization with deferred or async scripts