33

删除Google Blogger的默认CSS和JS

 4 years ago
source link: https://www.williamlong.info/archives/5893.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

删除Google Blogger的默认CSS和JS

2019-11-19 22:31:34 | 作者: 月光 | 分类: 网站建设 | 评论: 1 | 浏览: 1354

  我们在使用Google Blogger的时候,会发现即使使用自定义域名,页面内容也包含来自Google Blogger域名的CSS和JS文件,由于该域名从国内无法访问,因此会降低网站访问速度,为了加快网站加载速度,有必要删除系统默认加载的CSS和JS文件,下面我就讲述一下删除这些CSS和JS的方法。

  进入Google Blogger后台,点击“主题背景”,选择当前主题,选择“修改HTML”,进入HTML源代码修改界面。

  在内容开头,找到<html...>标签,在html后面增加如下内容

  b:css='false' b:js='false'

  修改完成后的代码类似下面一行内容。

  <html b:css='false' b:js='false' b:version='2' class='v2' expr:dir='data:blog.languageDirection' expr:lang='data:blog.locale' xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'>

  按CTRL-F,搜索</head>,将这一行替换为

  <!--</head>--></head>

  至此修改全部完毕,点击保存,将HTML模版保存。

  之后,再次打开刷新自己的Blogger网站,查看HTML源代码,会发现Google Blogger默认自带的CSS和JS都消失或者被注释,打开自定义域名的网站速度会明显加快。

  上述修改会有一些副作用,一个副作用是“布局”功能会出现显示异常,将第一步修改恢复回去之后会正常。其次对于某些模板会出现内容不居中的情况,可以在“布局”里添加HTML/JavaScript组件,写入如下代码:

<style type="text/css">

body {max-width: 960px;margin: auto;}

.column-center-outer,.column-left-outer,.column-right-outer{position:relative;float:left;_display:inline;_overflow:hidden}

.column-center-outer{width:100%}

.column-left-outer{margin-left:-100%}

</style>

删除Google Blogger的默认CSS和JS

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK