Sorry for the rudimentary question.
When I want to use cordova's js, should I use components loader.js?
The cordova project generated by cordova create
automatically loads cordova.js, so you don't need to write them directly in index.html or load them using loader.js.
The deviceready
event is triggered when the API provided by cordova becomes available, so you can pass the callback function to deviceready
to see if cordovaAPI is now available as follows:
document.addEventListener('device ready', function(){
// CordovaAPI is now available.
}, false);
To take advantage of non-cordova libraries (such as jQuery), write a script tag in index.html.
<script type="text/javascript" src="path/to/jquery.js">
In jQuery's ready
and Cordova's devicesready
, jQuery handles events better when they are ready, so you should receive devicesready
first.
As your project grows in size, the program may become stuck depending on the library load order, so consider using require.js.
When using Cordova, the JavaScript you specify is cordova.js
.This may not be the case if you are using a framework wrapped around Cordova, for example, Ionic calls at least cordova.js
.
(For example, <script src="cordova.js"></script>
)
This cordova.js
is not the type to download and deploy directly, such as jQuery, but is automatically generated in the folder of the platform when a corresponding platform is added, such as cordova platform add android
.
For Android examples, it should be generated below $ app folder/platforms/android/platform_www
.
801 GDB gets version error when attempting to debug with the Presense SDK (IDE)
848 M2 Mac fails to install rbenv install 3.1.3 due to errors
919 Uncaught (inpromise) Error on Electron: An object could not be cloned
1343 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2025 OneMinuteCode. All rights reserved.