is document.write blocking
I would like to insert a script into the page in a blocking way (can't use the src attribute of a script tag unfortunately). Would it block if i inserted the tag via document.write() on all browsers? I know this is a bad way of doing things, but i really need it to block the loading of other resources. Currently i'm d开发者_如何学Coing:
document.getElementsByTagName('head')[0].appendChild(dynamic_script_tag_created_previously);
But this is not good since it's an asynchroneous load.
Thanks for reading and thinking about it :)
Yes, for example:
<script>
document.write('<!doctype html><html id="sanitized"><head>'
+ document.head.innerHTML + '</head><body>'
+ document.body.innerHTML + '</body></html>');
</script>
Will lock up the browser for a few seconds.
精彩评论