在Pug和Jade文件中放置JS脚本是否重要?
当我们放置这样的行时,为什么页面加载速度更快:
script(src="/Scripts/jquery.timeago.js")
在我们的标签的末尾而不是在
说:
//Jade file with JQuery
!!! 5
html(lang="en")
head
title Holamundo!
script(type='text/javascript', src='.9.1.js')
body
h1#headTitle Hello, World
p#content This is an example of Jade.
script
$('#headTitle').click(function() {
$(this).hide();
});
$('#content').click(function() {
$(this).hide();
});
回答如下:
Pug模板将转换为HTML,然后将其发送到浏览器。
浏览器将以相同的方式解释HTML输出,无论其如何生成(手动,通过哈巴狗模板或其他系统)。
因此,你的问题最终是这个问题:Where should I put <script> tags in HTML markup?
进一步阅读:How exactly does <script defer="defer"> work?