Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I faced an issue where
cordova.js
wasn't loaded whenindex.js
was executed.In particular,
window.cordova
was undefined at this part. It would load later.I found the problem was that the
<script type="text/javascript" src="cordova.js"></script>
was placed below the</body>
. This would lead to the script loading after the app.To fix this,
cordova.js
should be placed somewhere such as before</head>
(which is where the css is linked). This ensures we have cordova when the app bootstraps.This can be verified by debugging the value of
window.cordova
inindex.js
with the current and new positions for the script tag. I only tested this on Android however.This is dangerous since otherwise it will ignore the
deviceready
event on a device, which could lead to using cordova before it's ready.