Is ordering of <link rel=“stylesheet” …> and [removed] tags significant?

前端 未结 7 1859
悲哀的现实
悲哀的现实 2021-01-11 09:53

(I apologize if this is an extremely basic question. I\'m a bit of an HTML noob.)

In HTML5, is the relative ordering within the element, o

相关标签:
7条回答
  • 2021-01-11 10:24

    In the general case, the order should be assumed to be significant. Because it can be. JavaScript code may, for example, try to access a link element, and then it matters whether the link element appears before the script element (in which case it exists in the DOM when the script is executed).

    0 讨论(0)
  • 2021-01-11 10:25

    Only one I can think of is the meta tag for IE...

    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    

    For IE to make use of that one, it has to be the first item in the head (AFAIK)...

    0 讨论(0)
  • 2021-01-11 10:31

    for performance, CSS first then JS...(but JS yields best performance at the end of the markup as noted in some of the other answers)

    stylesheets should always be specified in the head of a document for better performance, it's important, where possible, that any external JS files that must be included in the head (such as those that write to the document) follow the stylesheets, to prevent delays in download time.

    quote from Optimize the order of styles and scripts (from Google's "Make the Web Faster" Best Practices docs)

    0 讨论(0)
  • 2021-01-11 10:32

    It is always better you include style sheet in the header and the scripts at the bottom because, users have to wait till the JavaScript finishes loading, tags block parallel downloads.

    please look the following links\ Is the recommendation to include CSS before JavaScript invalid?

    0 讨论(0)
  • 2021-01-11 10:34

    No, there is no difference.

    The only thing you should consider is putting your <script> tags at the bottom of the <body>. For more information regarding this issue read this article by Yahoo.

    0 讨论(0)
  • 2021-01-11 10:38

    In terms for performance... include CSS files in the header and js files at the bottom of the page...

    In terms of order the order of css files and js files matter... in css file if the same rule is present in multiple files the later once will get precedence... in js file the depended files should be included first

    0 讨论(0)
提交回复
热议问题