LLVM BLOG

提高android文档加载速度

最近由于google被屏蔽,导致android的html文档加载速度特别慢,要想提高加载速度就需要将其中以下内容删除或注释掉
<link rel="stylesheet"
href="http://fonts.googleapis.com/css?family=Roboto+Condensed">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:light,regular,medium,thin,italic,mediumitalic,bold"
  title="roboto">
<script src="http://www.google.com/jsapi" type="text/javascript"></script>

由于html文档数量众多,一个一个修改近乎死人,今天花了些时间写了个脚本进行处理。
内容如下:
#!/bin/bash

if [ $# != 1 ]; then
   echo "please input document directory..."
   exit 1
fi

htmldir=$1
htmlfiles=`find $htmldir -type f -name '*.html'`


macos=false

case "`uname`" in
  Darwin* )
    macos=true
    ;;
esac



for file in $htmlfiles
do
  echo  "processing $file"
  if $macos;
  then
    sed -i '' 's/<script src="http:\/\/www.google.com\/jsapi" type="text\/javascript"><\/script>//g'  $file
    sed -i '' 's/<link rel="stylesheet"//g'  $file
    sed -i '' '/fonts.googleapis.com/d'  $file
  else
    sed -i  's/<script src="http:\/\/www.google.com\/jsapi" type="text\/javascript"><\/script>//g'  $file
    sed -i  's/<link rel="stylesheet"//g'  $file
    sed -i  '/fonts.googleapis.com/d'  $file
  fi
done

在终端中输入./xxx.sh     docs 
处理完毕再次打开文档是不是很快啊。


posted on 2014-08-09 14:52 LLVM 阅读(332) 评论(0)  编辑 收藏 引用 所属分类: bash


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


My Links

Blog Stats

常用链接

留言簿

随笔分类

随笔档案

文章分类

文章档案

搜索

最新评论

阅读排行榜

评论排行榜