From 873630dabfb045c3a04b38aaa4a4dcace08ceec6 Mon Sep 17 00:00:00 2001 From: Vaios Kalpias-Ilias Date: Mon, 7 Dec 2015 18:12:50 +0200 Subject: [PATCH] [FIX] Synchronous loading of scripts that are already loaded --- src/framework/components/script/script_component.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/framework/components/script/script_component.js b/src/framework/components/script/script_component.js index b2ede054bd8..dedbdee293b 100644 --- a/src/framework/components/script/script_component.js +++ b/src/framework/components/script/script_component.js @@ -134,8 +134,16 @@ pc.extend(pc, function () { var i, len; var cached = []; + var prefix = this.system._prefix || ""; + var regex = /^http(s)?:\/\//i; + for (i = 0, len = urls.length; i < len; i++) { - var type = this.system.app.loader.getFromCache(urls[i]); + var url = urls[i]; + if (! regex.test(url)) { + url = pc.path.join(prefix, url); + } + + var type = this.system.app.loader.getFromCache(url, 'script'); // if we cannot find the script in the cache then return and load // all scripts with the resource loader