官术网_书友最值得收藏!

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:

  1. 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:
    How to do it...
  2. Update the index.html file to include sencha-touch.js in place of sencha-touch-debug.js.
  3. 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 the ch01_01.js) and yapps-all.css (this may contain the merged sencha-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.

  4. Remove the inclusion of the individual application-specific JavaScript files and CSS files from index.html.
  5. Include yapps-all.js and yapps-all.css.
  6. 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
主站蜘蛛池模板: 克拉玛依市| 大荔县| 石嘴山市| 门头沟区| 铅山县| 嘉峪关市| 福清市| 纳雍县| 汪清县| 东方市| 阳春市| 铜梁县| 自治县| 安西县| 湛江市| 灯塔市| 道孚县| 马龙县| 德钦县| 正安县| 新兴县| 安吉县| 汾阳市| 宜川县| 昭觉县| 三都| 扶绥县| 铁力市| 乐东| 康定县| 南城县| 化德县| 普安县| 定陶县| 都安| 米易县| 吉林省| 都匀市| 东光县| 安泽县| 尼勒克县|