- Sencha Touch Cookbook
- Ajit Kumar
- 426字
- 2021-08-20 15:56:06
Setting up the production environment
This recipe describes the steps required to create a production-ready package of the application. These steps are mentioned for the Sencha Touch-related applications; however, they can also be applied to any JavaScript-based application.
Getting ready
Make sure that you have completed the steps outlined in the Setting up the browser-based development environment recipe.
How to do it...
Carry out the following steps:
- Trim down the Sencha Touch library by deleting the files and folders which are not required in the production environment. The following screenshot shows the files and folders which should be deleted from the
sencha-touch
folder: - Update the
index.html
file to includesencha-touch.js
in place ofsencha-touch-debug.js
. - Merge and minify your JavaScripts and CSS files. You may use the tool of your choice. Say you have created
yapps-all.js
(for now, it contains only thech01_01.js
) andyapps-all.css
(this may contain the mergedsencha-touch.css
and any of our application-specific CSS file, say,yapps.css
) as the merged and minified JavaScripts and CSS files, respectively.Note
Sencha uses and recommends JSBuilder and YUI Compressor and you can read more about this at the following URL:http://www.sencha.com/products/jsbuilder.
- Remove the inclusion of the individual application-specific JavaScript files and CSS files from
index.html
. - Include
yapps-all.js
andyapps-all.css
. - Deploy the application on your production server.
How it works...
In step 1, we removed the unwanted folders and files which are not required for a typical production deployment.
In step 2, we replaced the debug version of the library with the production ready version, which is a compressed and minified version of the debug version. This file will not have the comments and also the code is obfuscated.
In step 3, we merged all the JS/CSS files into one single file and minified them. You may want to find out the best way to combine the files. This is generally done to load the application quickly. You may choose to combine one or more files into one or create individual minified files. It is totally based on your project design and code structure.
In steps 4 and 5, we removed the individual inclusion of the JS and CSS files from index.html
and included the merged and minified ones. This recipe does not show the PhoneGap-related JS file. However, if your application is using it, then make sure that you also minify it, as the default one is not the production ready file.
See also
- The recipe named Setting up the browser-based development environment in this chapter
- The recipe named Setting up the Android-based development environment in this chapter
- Software Testing using Visual Studio 2012
- C#程序設計(慕課版)
- Web Development with Django Cookbook
- Python:Master the Art of Design Patterns
- Android程序設計基礎
- 第一行代碼 C語言(視頻講解版)
- 蘋果的產品設計之道:創建優秀產品、服務和用戶體驗的七個原則
- 執劍而舞:用代碼創作藝術
- Web性能實戰
- JBoss:Developer's Guide
- GitHub入門與實踐
- R語言:邁向大數據之路(加強版)
- C++ System Programming Cookbook
- Python Business Intelligence Cookbook
- 計算機輔助設計與繪圖技術(AutoCAD 2014教程)(第三版)