gpt4 book ai didi

javascript - JS 脚本在 Pug 和 Jade 文件中的位置重要吗?

转载 作者:行者123 更新时间:2023-11-30 14:52:47 25 4
gpt4 key购买 nike

为什么我们放置这样的行时页面加载速度更快:

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?

进一步阅读:How exactly does <script defer="defer"> work?

关于javascript - JS 脚本在 Pug 和 Jade 文件中的位置重要吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47874559/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com