From f29186115df2c22dab52ac29e0b69de36503d69c Mon Sep 17 00:00:00 2001 From: Pierre Rudloff <50333926+prudloff-insite@users.noreply.github.com> Date: Fri, 27 Nov 2020 14:30:09 +0100 Subject: [PATCH] Callback called too soon for external scripts When useExternalJs is enabled, the callback is called immediately for internal scripts because we don't have an onreadystatechange event (because the script is not inserted by tarteaucitron). However, for external scripts, we do want to wait for the event to be triggered. --- tarteaucitron.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tarteaucitron.js b/tarteaucitron.js index e98d9e4..687b76e 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -1598,7 +1598,7 @@ var tarteaucitron = { } if (typeof callback === 'function') { - if ( !tarteaucitron.parameters.useExternalJs ) { + if ( !tarteaucitron.parameters.useExternalJs || !internal ) { script.onreadystatechange = script.onload = function () { var state = script.readyState; if (!done && (!state || /loaded|complete/.test(state))) {