頁面中CSS載入方式的最佳化

來源:互聯網
上載者:User

      1、應該將 CSS 放置於結構的上方(一般放置於 head 元素內)。CSS 是解釋型語言,Firefox 和 IE 在等待 CSS 傳輸完成之前不會渲染任何東西。只有將 CSS 前置,才可在瀏覽器解析結構時,對頁面進行渲染。

This causes the blank white screen problem. The page is totally blank until the stylesheet at the bottom is downloaded, on the order of 6-10 seconds for this page. The browser is waiting for the stylesheet to be loaded before it renders anything else in the page, even the static text.

       導致的問題就是,頁面會有一段時間“樸素”,突然之間又“華麗”,使用者體驗很不好。

       2、盡量使用 <link rel=”stylesheet” href=”http://www.planabc/yuanxin.css” type=”text/css”> 的樣式匯入方式,而減少 @import 的使用,更勿使用多層嵌套的 @import 。因為在 IE 裡, @import 相當於將 <link> 放在頁面尾部。

This is a valid syntax, but, even though it’s in the document’s HEAD, it breaks progressive rendering and instead causes the blank white screen and Flash of Unstyled Content problems.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.