From 38919d6e9e7a3a786fd2ed0c7ccf0821f8f7b08e Mon Sep 17 00:00:00 2001 From: Matthew Andres Moreno Date: Thu, 18 Apr 2024 13:33:52 -0400 Subject: [PATCH] Fixup replacement of jquery ready() --- include/emp/web/events.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/emp/web/events.hpp b/include/emp/web/events.hpp index edcff1d2c..a33b8ecbd 100644 --- a/include/emp/web/events.hpp +++ b/include/emp/web/events.hpp @@ -34,7 +34,8 @@ namespace web { (void) fun_id; MAIN_THREAD_EM_ASM({ - document.addEventListener('DOMContentLoaded', function() { + if (document.readyState !== 'loading') emp.Callback($0); + else document.addEventListener('DOMContentLoaded', function() { emp.Callback($0); }); }, fun_id);