We should add a field on ScriptLoader that tracks whether the element was written via document.write.
This will be useful in metrics to improve performance of loading these scripts.
A first pass implementation will be to introspect ownerDocumentForCurrentNode().isInDocumentWrite(). However, if the tokenizer/parser is blocked waiting for scripts when the element is inserted, this mechanism will not work. We won't construct the element until the document.write call is completed.
Instead, we will need to do something cleverer like keeping track of untokenized string positions.
Comment 1 by csharrison@chromium.org
, Apr 5 2016