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

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
主站蜘蛛池模板: 伊川县| 固镇县| 湖口县| 兴业县| 三门县| 棋牌| 梨树县| 洪雅县| 科尔| 宝清县| 清远市| 布尔津县| 河南省| 皮山县| 张家港市| 湾仔区| 古交市| 新建县| 荔浦县| 柯坪县| 乌恰县| 玉树县| 莎车县| 临西县| 溧阳市| 辽宁省| 万全县| 新河县| 长垣县| 古蔺县| 石渠县| 谢通门县| 都匀市| 宜都市| 靖江市| 敖汉旗| 绍兴市| 黄骅市| 临高县| 邛崃市| 全南县|