scastie
scastie copied to clipboard
Is it possible to load script with defer?
Embedded Scastie script seems to block html rendering.
I tried defer
and async
but it raises the error. 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.
<script src="https://scastie.scala-lang.org/*****************.js" defer></script>
Can document.write
be replaced with innerHTML
,appendChild
or something similar?
@i10416 can you give me a sample scastie which demonstrates the problem?
Hi @OlegYch , I'm encountering the same issue, even with a Hello World snippet like this one.
Copying the following into an index.html
file and opening that in Chrome is enough to reproduce the issue for me.
<script src="https://scastie.scala-lang.org/DqxgfTAUR4Ch3Ja5KBCL1w.js"></script>
In dev tools, this produces the error message:
A parser-blocking, cross site (i.e. different eTLD+1) script, https://icvm0042.epfl.ch/embedded.js, 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.
The suggestion from Stack Overflow is to make the script async
, but that produces the error that @i10416 is seeing.