您好,CSS压缩优化是在保持原有功能的情况下减少CSS的体积,以达到更好的访问速度。
如何判断css代码是否压缩优化
从书写格式上可以轻易分辨:
例原版CSS代码为:
1、blockquote:before,blockquote:after,
2、q:before,q:after{
3、content:'';
4、content:none;
5、}
压缩后代码为:
blockquote:before,q:after,q:before{content:'';content:none}
网络中有许多在线美化和压缩的工具
CSS压缩方法
目前我所做的项目是把各个模块下的分css,压缩到一个统一的resource目录下统一管理。本项目用的是nodejs,因为这一版本里已经集成了require。js,所以不需引用,require。js的压缩库其实是r。js,所以还需要引用一下,然后通过dos命令写一个bat文件
@echooff
noder。js-ocssIn=html_Report/css/main。cssout=resources/default/html_report_main。cssoptimizeCss=standard
noder。js-ocssIn=html_Report/css/detail。cssout=resources/default/html_report_detail。cssoptimizeCss=standard
noder。js-ocssIn=html_Report/css/structure。cssout=resources/default/html_report_structure。cssoptimizeCss=standard
noder。js-ocssIn=html_Notice/css/main。cssout=resources/default/html_notice_main。cssoptimizeCss=standard
…
//下面这段相当于一个日子文件
echoCACHEMANIFEST>html_Report/report。appcache//创建
echo,#%date%-%time%>>html_Report/report。appcache//追加
echo,NETWORK:>>html_Report/report。appcache
echo,*>>html_Report/report。appcache
echo,CACHE:>>html_Report/report。appcache
echo,/resources/default/html_report_structure。css>>html_Report/report。appcache
echo,/resources/default/html_report_main。css>>html_Report/report。appcache
echo,/resources/default/html_report_detail。css>>html_Report/report。appcache
echo,/resources/default/images/tab_sprite。png>>html_Report/report。appcache
echo,/resources/default/images/attachment_sprite。gif>>html_Report/report。appcache
echo,/js/seajs2。0/sea。js>>html_Report/report。appcache
exit








