Thanks! Fixed. Note though RE your example generator, the defer
attribute is not valid for 'inline' scripts - it's only valid for URL/remote scripts (i.e. using src
attribute instead of writing text between the opening and closing script tags). Here are some options for running code after everything else has executed:
document.addEventListener("DOMContentLoaded", function() { yourCodeHere })
- this is usually your best option (and by coincidence was already supported, since Cocell reported a similar issue a week or so ago)window.addEventListener("load", function() { yourCodeHere })
- same aswindow.onload = function() { yourCodeHere }
butaddEventListener
a much better approach because it doesn't overwrite theonload
function that might have been set by some other code (e.g. if you're writing a plugin, you might overwrite the importer'sonload
function that they set). With theaddEventListener
approach you can add as many as you want. But in general usingwindow
'sload
event isn't desirable because it also waits for stuff like images to finish loading before triggering. But if that's what you want, then use this.- As you mentioned, you can put a square block at the end of the HTML panel like
[ yourCodeHere ]
, but note that this will run again after everyupdate()
. If you only want it to run once, you'd have to write something like[doneStuffAlready ? "" : doStuff(), doneStuffAlready=true]