I just created a new GitHub repository containing a new boilerplate for my Cordova mobile applications.
See it in GitHub
I decided to open source this project in order to provide to you, developers, a production-ready simple Cordova application so that you can boost your development.
This Cordova boilerplate is an extremely simple Cordova app that can be used as boilerplate for apps developed with modularity and performance in mind.
The proposed boilerplate has been developed with MODULARITY and PERFORMANCE in mind, it should be totally memory leaks free and ready-to-be-used in production.
As a reference, give a look at the main.js file in www/js/main.js, it contains:
- configuration map for keeping all the used libraries organized and easily interchangeable
- a close method for closing each view and managing all its inner views and bound events
- a changePage method for the Backbone Router that manages to switch between mobile app pages in a generic and reusable manner
- generic function to show a web page within a Cordova application and checking if the user has an Internet connection
- other useful functions are spread within the boilerplate, such as mobile-friendly CSS3 stylesheet, organization of the project in semantic directories (like: templates, js, img), etc.
Please, if you find some bugs or aspects to be enhanced, drop be a line!
Used frameworks:
- Backbone 1.1.0: a JavaScript MVC framework for giving structure to (mobile) web apps
- RequireJS 2.1.9: a JavaScript file and module loader for keeping your Javascript codebase modular and well organized
- Handlebars 1.2.0: a minimal templating engine based on Mustache
- Zepto 1.1.2: minimalist JavaScript library for DOM traversing, event handling, animations, etc.
- Leaflet 0.7.1: a Javascript library for embedding maps in your own web pages.
Basically, the web app is composed of two simple views (represented as different Handlebars templates), backed by a JavaScript module defined using Require JS. Zepto (or jQuery) is used as a convenience library.
The web app is purposefully super-simple, it shows a structural view containing the two basic views (it is supposed to be used as navigation hub). Then, the first view contains a string that can be filled dynamically by the Backbone model behind it, and the second view shows a Leaflet map centered on L’Aquila, the city I currently live in.
See it in GitHub
[…] you are interested in using the guidelines I provide in the seminars, please look at my previous post in which I present the source code of a Cordova application boilerplate implementing the guidelines […]
Thank you so much for the boilerplate. This is really helpful to get started with the awesome Javascript libraries combination.
Thank you! 🙂
Really cool boilerplate man!! Thanks
Just one question, this does not work on android 2.3.3, right?.. do you know why?
Hi Diego,
according to the Apache Cordova documentation for the Android platform
my boilerplate should work on Android 2.3.3, because Cordova supports Android 2.3.x (Gingerbread, starting with Android API level 10)
and 4.x. As a general rule, Android versions become unsupported by Cordova as
they dip below 5% on Google’s distribution dashboard.
Android versions earlier than API level 10, and the 3.x versions (Honeycomb,
API levels 11-13) fall significantly below that 5% threshold.