Opened 8 years ago
Last modified 8 years ago
#16676 confirmed New Feature
Improvements in loading the debug code for async
Reported by: | Robert Flaherty | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | General | Version: | 4.0 |
Keywords: | Cc: |
Description
Steps to reproduce
- Add async="async" into the script tag for ckeditor.js.
- Launch the HTML in FF.
- It may take a few launches, with or without clearing the cache, but look for a console error.
Expected result
Script would load normally.
Actual result
"A call to document.write() from an asynchronously-loaded external script was ignored." in the console.
Other details (browser, OS, CKEditor version, installed plugins)
FF50, Win7, 4.5.11, many plugins.
I've been running into issues with the debug code being used with RequireJS. This use case is a simplified example of the first issues I hit.
This may be moot with the 5.x line and the AMD branch, but for 4.x, a few tweaks can be added. I altered the debug ckeditor.js and core/loader.js and added to the test:
if ( document.body && ( !document.readyState | | document.readyState == 'complete' | | document.readyState == 'interactive' | | (document.currentScript && document.currentScript.async) ) )
Per the web, "interactive" does still mean the doc is loaded and parsed, while still waiting on images/script/frames, so adding a script node sounds legal.
For the currentScript.async test, if this script was loaded with async, writing to the doc should never be allowed. This flag didn't seem to pickup if a script calling this script was async, so its' not perfect.
Additionally, I wasn't sure if there was a benefit to doing "document.getElementsByTagName("head")[0].appendChild(script)" instead of "document.body.appendChild(script)".
Change History (1)
comment:1 Changed 8 years ago by
Keywords: | load debug async removed |
---|---|
Status: | new → confirmed |
Type: | Bug → New Feature |
Version: | 4.5.11 → 4.0 |
This is more of a feautre request than a bug because at the moment we simply don't provide support for "async".
Anyway you are right - when async is used the
document.wrtie
should not be called. One reason is that when page has already been loaded, usingdocument.write
will calldocument.open
which will wipe out the existing page. In such case having editor clearing a whole page doesn't sound too good.