1. It indicates that when extjs is used, it is relatively slow to run, especially when there are too many running data and js, it may become stuck or wait for a long time.
There are many optimization methods to solve this problem. One of them today is to remove and merge spaces and comments in js during Ant script packaging, this has not yet been implemented.
2. First, prepare two. jar files, YUIAnt. jar and yuicompressor-2.4.x.jar.
3. attachments to the two files
4. the build. xml file is as follows:
Copy codeThe Code is as follows:
<! -- Temporary directory during JS Compression -->
<Property name = "jsDir" value = "$ {basedir}/release/web/js"/>
<! -- Temporary directory during CSS Compression -->
<Property name = "cssDir" value = "$ {basedir}/release/web/css"/>
<! -- Ext3 temporary directory during css Compression -->
<Property name = "cssExtDir" value = "$ {basedir}/release/web/ext3"/>
<! -- Ext3 temporary directory during js Compression -->
<Property name = "extUxJsDir" value = "$ {basedir}/release/web/ext3/ux"/>
<! -- JS source file -->
<Property name = "jsSourceDir" value = "$ {webapp}/js"/>
<! -- CSS source file -->
<Property name = "cssSourceDir" value = "$ {webapp}/css"/>
<! -- Ext CSS source file -->
<Property name = "cssExtSourceDir" value = "$ {webapp}/ext3"/>
<! -- Ext JS source file -->
<Property name = "extUxJsSourceDir" value = "$ {webapp}/ext3/ux"/>
<! -- Yui dependency package -->
<Path id = "yuiClasspath">
<Fileset dir = "$ {basedir}">
<Include name = "metadata/tools/yui/yuicompressor-2.4.2.jar"/>
<Include name = "metadata/tools/yui/YUIAnt-zh_CN.jar"/>
</Fileset>
</Path>
Copy codeThe Code is as follows:
<! -- Start compressing JS -->
<Target name = "copy-web-depress-js" depends = "init">
<Delete dir = "$ {basedir}/release/web"/>
<Copy todir = "$ {basedir}/release/web">
<Fileset dir = "$ {webapp}"/>
</Copy>
<Taskdef name = "uxJsCompress" classname = "com. yahoo. platform. yui. compressor. YUICompressTask">
<Classpath>
<Path refid = "yuiClasspath"/>
</Classpath>
</Taskdef>
<UxJsCompress linebreak = "9000000" warn = "false" charset = "UTF-8" encoding = "UTF-8" munge = "yes" preserveallsemicolons = "true" outputfolder = "$ {extUxJsDir }">
<Fileset dir = "$ {extUxJsSourceDir}">
<Include name = "**/*. js"/>
</Fileset>
</UxJsCompress>
<Taskdef name = "yuicompress" classname = "com. yahoo. platform. yui. compressor. YUICompressTask">
<Classpath>
<Path refid = "yuiClasspath"/>
</Classpath>
</Taskdef>
<Yuicompress linebreak = "9000000" warn = "false" charset = "UTF-8" encoding = "UTF-8" munge = "yes" preserveallsemicolons = "true" outputfolder = "$ {jsDir }">
<Fileset dir = "$ {jsSourceDir}">
<Include name = "**/*. js"/>
</Fileset>
</Yuicompress>
<Taskdef name = "cssYuicompress" classname = "com. yahoo. platform. yui. compressor. YUICompressTask">
<Classpath>
<Path refid = "yuiClasspath"/>
</Classpath>
</Taskdef>
<CssYuicompress linebreak = "9000000" warn = "false" charset = "UTF-8" encoding = "UTF-8" munge = "yes" preserveallsemicolons = "true" outputfolder = "$ {cssDir }">
<Fileset dir = "$ {cssSourceDir}">
<Include name = "**/*. css"/>
</Fileset>
</CssYuicompress>
<Taskdef name = "cssExtYuicompress" classname = "com. yahoo. platform. yui. compressor. YUICompressTask">
<Classpath>
<Path refid = "yuiClasspath"/>
</Classpath>
</Taskdef>
<CssExtYuicompress linebreak = "9000000" warn = "false" charset = "UTF-8" encoding = "UTF-8" munge = "yes" preserveallsemicolons = "true" outputfolder = "$ {cssExtDir }">
<Fileset dir = "$ {cssExtSourceDir}">
<Include name = "**/*. css"/>
</Fileset>
</CssExtYuicompress>
</Target>
<! -- End compression JS -->
5. Here, YUIAnt. jar does not support UTF-8 character sets when JavaScript compression is used. That is
Copy codeThe Code is as follows:
Encoding = "UTF-8
7. My personal feelings have been around for a long time. I thought it could improve the js loading speed. The result is still a little slow, not as fast as jquery, it is estimated that gzjs compression will speed up. Now I have analyzed that it is slower to run in IE, and faster in firefox. It seems that there are still a lot of js loaded in each module.
Comparison of optimization speed: