Skip to content

Instantly share code, notes, and snippets.

@chalettu
Created July 14, 2017 14:57
Show Gist options
  • Save chalettu/b59b4dee08c80939b2d6f0e79e49c462 to your computer and use it in GitHub Desktop.
Save chalettu/b59b4dee08c80939b2d6f0e79e49c462 to your computer and use it in GitHub Desktop.
Conditionally loading cordova
// put this in your main.js
// add cordova.js only if serving the app through file://
if (window.location.protocol === 'file:' || window.location.port === '3000') {
var cordovaScript = document.createElement('script')
cordovaScript.setAttribute('type', 'text/javascript')
cordovaScript.setAttribute('src', 'cordova.js')
document.body.appendChild(cordovaScript)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment