标签:shell 压缩 javascript
关于javascript代码文件的压缩在之前的文章中提到过(http://blog.csdn.net/u010487568/article/details/19701575),一般来说有三种方式:
#
#!/usr/bin
#
########################################################
#Filename: compreee-js.sh
#Author : Oshyn Song
#Time : 2014-8-19
#Desc : compress the javascript file by basic method
########################################################
if [ $# -ne 1 ];
then
echo "Usage: sh $0 js-filename";
exit;
fi
jsfile=$1;
echo "Compress $jsfile start ...";
cat -s $jsfile | sed 's!//.*$!!g' | tr -d '\n\t' | tr -s ' ' | sed 's!/\*.*\*/!!g' | sed 's! \?\([+=\!&%$\*\|><{}();,:]\) \?!\1!g' > "compress.${jsfile}";
echo "process finished.";;(function(){
function __(id){
return document.getElementById(id);
}
function Ajax(options){
if (typeof XMLHttpRequest == 'undefined'){
XMLHttpRequest = function(){
return new ActiveXObject(
navigator.userAgent.indexOf('MSIE 5') >= 0 ?
'Microsoft.XMLHTTP' :
'Msxml2.XMLHTTP'
);
};
}
..........压缩后代码:;(function(){function __(id){return document.getElementById(id);}function Ajax(options){if(typeof
XMLHttpRequest=='undefined'){XMLHttpRequest=function(){return new ActiveXObject(navigator.userAgent.indexOf('MSIE 5')>=0 ?'Microsoft.XMLHTTP':'Msxml2.
XMLHTTP');};}
.......shell文本处理——最基本方法压缩js文件,布布扣,bubuko.com
标签:shell 压缩 javascript
原文地址:http://blog.csdn.net/u010487568/article/details/38685029