Sencha Touch - Builds
Today's demand for a web application is to develop a fast application with less development efforts. Sencha Touch helps in doing so with ease as it provide a number of build libraries to choose from, based on the development or production code along with the facility to create a custom build.
Sencha Touch build libraries loads the classes dynamically. Dynamic loading stands for the classes that gets loaded when required and only those classes will be included which are required in the application. This makes the application run faster as the number of files to be loaded reduces, simultaneously decreasing the time to load.
Sencha Touch 2.x provides the following five build libraries.
|Sr.No.||Builds & Usage|
This build is used while developing the application locally. It is a nonminified version with all the comments and debug logs for easy debugging while development.
This file is used for production purpose. It is the minified version when we have a custom build.
This file is used for production purpose. It is the minified version when we do not have a custom build.
This file is used for debugging in production. It is not minified and has all the comments and debug logs.
This build is used to migrate the version 1.x to version 2.x. It gives a warning wherever version 1.x code is not compatible and needs code modification.
With the above mentioned builds, Sencha Touch provides a facility to create custom builds.
Advantages of Having a Custom Build
Custom build does not load all the touch files. It loads only those files, which we are using in the application, which makes the application faster and easily maintainable.
Sencha CMD is used to create a custom build. To create a custom build in Sencha CMD, go to the directory where the app file resides and type one of the following commands to create a build.
|Sr.No.||Command & Usage|
sencha app build native
Builds the app and prepares a file called packager.temp.json that you can use to package an application--the packager.temp.json is the same as packager.json, but contains additional paths.
sencha app build -run native
Builds and automatically packages the application, and launches the appropriate simulator.
sencha app build package
Builds the app with packaging support, but does not configure a packager JSON file. This is useful for projects that manually maintain multiple packager.json files.
Once the build is successful, it will generate all-classes.js file which we need to include in our index.html to make it production ready.
Following code shows the changes to be done for production ready code.
Index.html before building application
Index.html after building the application