From 4adfcb3dad78390589bcf70b67fe066bfffdd19d Mon Sep 17 00:00:00 2001 From: Agnel Waghela Date: Sat, 10 Nov 2012 19:40:33 +0530 Subject: [PATCH 1/2] change of execute function ### Change of Execute Function I re-wrote the *execute* function for the file to inject it according to the extension i.e **.js** or **.css** if the extension is other than .js or .css it won't be loaded or even cached! --- bootup.js | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/bootup.js b/bootup.js index a4c44bd..2fd25be 100644 --- a/bootup.js +++ b/bootup.js @@ -163,18 +163,30 @@ var BootUp = function (files, options) { } /** - * Injects a JS file into the page. + * Injects a JS or CSS file into the page. * @private * @param loaded the loaded data object. */ function execute(loaded) { - if (loaded.path.indexOf(".js") === -1) { - return; - } - var script = document.createElement("script"); - script.type = "text/javascript"; - script.text = loaded.data; - document.body.appendChild(script); + // extension of the file + var ext = (loaded.path.split('.')[1] === "min" || loaded.path.split('.')[1] === "pack")? loaded.path.split('.')[2] : loaded.path.split('.')[1]; + console.log(ext) + switch( ext ) { + case "js": + var script = document.createElement("script"); + script.type = "text/javascript"; + script.text = loaded.data; + document.head.appendChild(script); + break; + case "css": + var style = document.createElement("style"); + style.type = "text/css"; + style.textContent = loaded.data; + document.head.appendChild(style); + break; + default: + return; + } } /** From 1086d5787a0b30b2c31d6dc723c1cb0288ea1c03 Mon Sep 17 00:00:00 2001 From: Agnel Waghela Date: Wed, 14 Nov 2012 00:51:14 +0530 Subject: [PATCH 2/2] updated to use debug as mentioned by Daniel(djmc) use of debug method! --- bootup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootup.js b/bootup.js index 2fd25be..95d4646 100644 --- a/bootup.js +++ b/bootup.js @@ -170,7 +170,7 @@ var BootUp = function (files, options) { function execute(loaded) { // extension of the file var ext = (loaded.path.split('.')[1] === "min" || loaded.path.split('.')[1] === "pack")? loaded.path.split('.')[2] : loaded.path.split('.')[1]; - console.log(ext) + debug( "Extension of the File", ext); switch( ext ) { case "js": var script = document.createElement("script");