文档中心 >Google PageSpeed

避免meta标签指定字符集

概览

在Internet Explorer8浏览器,在meta http-equiv标签指定字符集将不能超前下载,不能先行下载会大大增加加载页面的时间。

操作

例如如下的meta标签设置了字符集

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>example</title>
  5. <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
  6. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  7. <meta content="avoid setting charset in meta tag" name="description">
  8. <meta content="meta,charset" name="keywords">
  9. </head>
  10. <body>
  11. <!-- content -->
  12. </body>
  13. </html>

应把设置charset的meta标签去掉,改在http响应头指定字符集。

Web开发人员应在HTTP的Content-Type响应头指定字符集,因为这可以确保先行下载的性能优势得以实现。(参见:在服务器设置字符集