jQuery Script included at bottom of page in mvc 4 template

后端 未结 3 526
情书的邮戳
情书的邮戳 2021-01-18 12:34

I was looking at the MVC 4 release candidate and the default Internet template that is included. I noticed that in the _Layout.cshtml, they are including the jQuery bundle a

相关标签:
3条回答
  • 2021-01-18 13:02

    This is generally done for performance. Look at the Yahoo performance guidelines.

    http://developer.yahoo.com/performance/rules.html/

    They explain why scripts can be better at the bottom.

    0 讨论(0)
  • 2021-01-18 13:02

    For some sites where jquery ui themes is used, it's better to have jquery and the jquery-ui at the top. That way the flash of unstyled content can be kept to a minimum.

    An other technique is to hide jquery themed elements initially, but that could give an impression of a slower loading time.

    0 讨论(0)
  • 2021-01-18 13:07

    I can't answer specifically for this case, but the idea is generally that the browser is attempting to render the page in approximately document order. Having the scripts included last means that the renderer can do its work and render the static portions of the page, and then the scripts will be loaded. I couldn't give any concrete figures on how much it really affects the user experience, but the idea is to make it such that the page is viewable before the scripts have finished loading.

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