What are best practices to order elements in <head>?

后端 未结 7 1353
有刺的猬
有刺的猬 2020-12-12 10:34

can use anything in any order? does placing of is important before

7条回答
  •  無奈伤痛
    2020-12-12 10:55

    You want your content-type first as this denotes the character encoding, otherwise if it comes later on, some browsers attempt to guess the encoding. (I can't remember the specifics, but I think IE will guess if it doesn't find an encoding in the first 75 characters of the document?)

    Most webservers send the encoding in the HTTP headers, but if a user saves your page, the headers aren't saved with it.

    I'd put CSS references second so the browser downloads them as soon as possible.

    JavaScript I wouldn't put in the head, it should go at the bottom of your pages as downloading them blocks rendering of pages.

提交回复
热议问题