From 0d73026160fd392dc823e9a70aeaef3f97efb0b9 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 6 Apr 2017 14:12:13 -0400 Subject: [PATCH] Fix script loading race condition --- js/Common.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/js/Common.js b/js/Common.js index fae46f6495..691df6c15e 100644 --- a/js/Common.js +++ b/js/Common.js @@ -243,10 +243,13 @@ if (!CRM.vars) CRM.vars = {}; var script = document.createElement('script'); scriptsLoaded[url] = $.Deferred(); script.onload = function () { - if (window.jQuery === CRM.$ && CRM.CMSjQuery) { - window.jQuery = CRM.CMSjQuery; - } - scriptsLoaded[url].resolve(); + // Give the script time to execute + window.setTimeout(function () { + if (window.jQuery === CRM.$ && CRM.CMSjQuery) { + window.jQuery = CRM.CMSjQuery; + } + scriptsLoaded[url].resolve(); + }, 100); }; // Make jQuery global available while script is loading if (window.jQuery !== CRM.$) { -- 2.25.1