Plugins implement order during document loading state
[issue link]Hi I am using CNZZ(an analyse platform) to analyse my website. It use document.write instead of Node.insertBefore(It also invokes document.write in the imported js file, so no matter I use insertBefore or not will experience below case)
Below is what I do to import it:
// plugins/umeng.js
if (process.env.NODE_ENV === 'production') {
document.write(unescape("%3Cspan id='cnzz_stat_icon_1263089026'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s13.cnzz.com/z_stat.php%3Fid%3D1263089026%26show%3Dpic1' type='text/javascript'%3E%3C/script%3E"))
}
// nuxt.config.js
plugins: [
{ src: '~plugins/umeng.js', ssr: false } // 1.0.0-alpha.4
{ src: '~/plugins/umeng.js', ssr: false } // 1.0.0-rc3
]
When I use 1.0.0-alpha.4 I met this warning
A Parser-blocking, cross site (i.e. different eTLD+1) script, http://s13.cnzz.com/z_stat.php?id=1263089026&show=pic1, is invoked via document.write. The network request for this script MAY be blocked by the browser in this or a future page load due to poor network connectivity. If blocked in this page load, it will be confirmed in a subsequent console message.See https://www.chromestatus.com/feature/5718547946799104 for more details.
It still works though it looks ugly, but when I tried to migrate Nuxt to 1.0.0-rc3 I met this
Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.
It cannot work!
Then I set a breakpoint at the code where I invoke document.write, I typed docment.readyState in the console when the program was paused
output loading when using 1.0.0-alpha.4
output interactive when using 1.0.0-rc3
So I wanna know where can I place the document.write to ensure it implement when the state of document is still loading?
Thanks in advance.