Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

phoneGap startup - do we need all those files?

Tags:

cordova

Alright, I am just getting started with phoneGap for iOS and I am noticing in the www directory that there are plenty of files, such as

spec/helper.js
spec/index.js
jasmine
cordova.js
etc.

Are all those things really needed in order to have it all working? Also, I noticed in "index.js" that, at the beginning of the file, it is creating an app object:

var app = { ... };

and puts all the code inside it;

Is this also necessary in order to bind the events? Like deviceready or others?

Thanks in advance.

like image 462
john smith Avatar asked Oct 20 '12 08:10

john smith


3 Answers

The cordova js the only js file needed. This is autogenerated when you ran the phonegap create script.

index.js contains sample code on how to bind to the deviceready event. It can serve as a start for your js code.

The spec folder and spec.html are for javascript testing using Jasmine, a BDD testing framework for Javascript.

like image 186
Matt Magpayo Avatar answered Nov 04 '22 04:11

Matt Magpayo


Even if the cordova js the only js file needed, you will probably not use some functions that it contains.

In fact, somewhere in your project you have a config xml file that contains all plugins used by your application (the location of this file dépends on your project Platform). Check this file and remove all unused plugins if you want to have a more performant application. After that, you can remove related functions in the cordova js file (this file interfaces plugins in native code with javascript).

For example, if you don't want to use compass features of your device, remove the corresponding plugin from the config xml file and also all functions related to the compass in the cordova js file (to perform this operation often save your file and test your project to check if you don't insert some syntax errors).

I send you a french blog post that gives some other good advices about phonegap performance. Maybe you can use Google translation to read this article...

http://blog.workinday.com/application_smartphone/184-comment-ameliorer-les-performances-de-son-application-phonegap.html

Hope this helps ! Bye !

like image 26
Antoine Avatar answered Nov 04 '22 05:11

Antoine


No, you don't need all these files.
Actually, the only file you need is cordova.js.

like image 4
Stan Avatar answered Nov 04 '22 05:11

Stan