JavaScript檔案的縮制 minification-of-the-javascript-files

縮制會從原始程式碼中移除多餘的字元,例如空格、新行和註解。 這藉由減少程式碼大小來改善效能。 雖然縮制不會影響功能,但會降低程式碼的可讀性。

若要產生語意變更的縮製程式碼,請按照下列步驟操作。

  1. 從檔案系統上的src-package複製client-html/src/main/webapp/js

    note note
    NOTE
    如需封裝的詳細資訊,請參閱自訂AEM Forms工作區簡介
  2. 針對新增/更新的模型/檢視,更新位於client-html/src/main/webapp/js下方的main.js中的路徑。

    例如,新增新的Sharequeue模型(例如mySharequeue)會變更:

    code language-javascript
    sharequeuemodel : pathprefix + 'runtime/models/sharequeue',
    

    code language-javascript
    sharequeuemodel : pathprefix + 'runtime/myModels/mySharequeue',
    
  3. 更新registry-config.xml, located at client-html/src/main/webapp/js/resource_generator,,以防main.js中別名變更/新增。

    例如,新增新的Sharequeue模型(例如mySharequeue)會變更:

    code language-xml
    <sharequeue
                name="sharequeue"
                path="runtime/models/sharequeue.js"
                service="service"/>
    

    code language-xml
    <sharequeue
                name="sharequeue"
                path="runtime/myModels/mySharequeue.js"
                service="service"/>
    
  4. 在client-html/src/main/webapp/js/minifier,執行命令:

    code language-shell
    mvn clean install
    

    它會使用縮小的main.js和registry.js來產生client-html/src/main/webapp/js底下的縮小檔案資料夾。

NOTE
縮制僅適用於64位元JVM。
NOTE
若您縮制,您的升級會受到影響。
recommendation-more-help
19ffd973-7af2-44d0-84b5-d547b0dffee2