为什么我们放置这样的行时页面加载速度更快:
script(src="/Scripts/jquery.timeago.js")
在我们标签的末尾,而不是在
说:
//Jade file with JQuery
!!! 5
html(lang="en")
head
title Holamundo!
script(type='text/javascript', src='http://code.jquery.com/jquery-1.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 输出,而不管它是如何生成的(手动、通过 pug 模板或其他系统)。
因此您的问题最终是这个:Where should I put <script> tags in HTML markup?
关于javascript - JS 脚本在 Pug 和 Jade 文件中的位置重要吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47874559/