关于Chrome浏览器加载某些CSS文件超慢或超时的奇葩问题的解决办法

<pre name="code" class="css">/*! normalize.css v3.0.2 | MIT License | git.io/normalize */
html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}h1{font-size:2em;margin:0.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace, monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:0.35em 0.625em 0.75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:bold}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}


这是我的CSS源代码,压缩了的。

(以下都是基于Chrome浏览器)

把这个文件放在有些服务器上去引用,完全正常。


但是我在阿里云上买的空间,使用chrome加载这个css就超慢,看图



居然用了2.2分钟,这还要人活吗?


而当我把引用换成我的另外一个网站(文件是一模一样)时,一切正常(我这个V5bjq网站也引用这个文件,也一切正常)




有人说两次的文件大小都不一样,远程那个2.3kb,本地那个1.4kb,这我就不知道为嘛了,反正两个文件确实是一模一样包括注释都一样,切都是压缩在一行了的。


当我引用外域的这个文件时候,没有问题,说明可能是服务器/空间什么地方的问题。怎么解决呢?


感觉问题可能是出在 css 代码内容上了,于是尝试几种方法修改了下,

只调换代码顺序没有用,
但修改任意参数值后加载就正常了,
或者中间或末尾加个空行也行

感觉应该并不是某个样式导致的

所以最好也最简单的方法就是在所有 css 代码末尾都空一行吧,也就是把压缩版css文件里的"}"批量替换成"\}\n",或者使用其他工具直接格式化css文件

这样 Chrome 加载就正常了,对这种BUG实在无语






                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值