Opened 3 years ago

Last modified 2 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

  1. Add async="async" into the script tag for ckeditor.js.
  2. Launch the HTML in FF.
  3. 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 2 years ago by Jakub Ś

Keywords: load debug async removed
Status: newconfirmed
Type: BugNew Feature
Version: 4.5.114.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, using document.write will call document.open which will wipe out the existing page. In such case having editor clearing a whole page doesn't sound too good.

Last edited 2 years ago by Jakub Ś (previous) (diff)
Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy