diff --git a/src/core/friendly_errors/sketch_reader.js b/src/core/friendly_errors/sketch_reader.js index eac502f51f..0924bd8a85 100644 --- a/src/core/friendly_errors/sketch_reader.js +++ b/src/core/friendly_errors/sketch_reader.js @@ -403,6 +403,6 @@ if (typeof IS_MINIFIED !== 'undefined') { p5._fesCodeReader = fesCodeReader; - window.addEventListener('load', p5._fesCodeReader); + window.addEventListener('p5Ready', p5._fesCodeReader); } export default p5; diff --git a/src/core/init.js b/src/core/init.js index 4a42d258ed..9cecfca8a8 100644 --- a/src/core/init.js +++ b/src/core/init.js @@ -25,6 +25,9 @@ const _globalInit = () => { } if (!window.mocha) { + const p5ReadyEvent = new Event('p5Ready'); + window.dispatchEvent(p5ReadyEvent); + // If there is a setup or draw function on the window // then instantiate p5 in "global" mode if (