Created
August 31, 2012 23:33
-
-
Save max-mapper/3561076 to your computer and use it in GitHub Desktop.
phonegap conditional script loader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// require this script before your document is done loading | |
;(function () { | |
var isDroid = navigator.userAgent.match(/Android/) | |
var isiOS = navigator.userAgent.match(/(iPhone|iPod|iPad)/) | |
var droidScripts = [ | |
"script/cordova-android.js", | |
"script/android-utils.js", | |
"script/cdv-plugin-childbrowser-android.js", | |
"script/cdv-plugin-datepicker.js", | |
"script/cdv-plugin-statusbarnotification.js", | |
"script/cdv-plugin-gcm.js" | |
] | |
var iosScripts = [ | |
"script/cordova-ios.js", | |
"script/cdv-plugin-pushnotification.js", | |
"script/cdv-plugin-childbrowser-ios.js" | |
] | |
if (isDroid) droidScripts.forEach(loadScript) | |
if (isiOS) iosScripts.forEach(loadScript) | |
function loadScript(src) { | |
var line = '<script type="text/javascript" charset="utf-8" src="' + src + '"></script>'; | |
document.writeln(line); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment