javascript - 是否有一个库允许我在页面底部加载 jQuery 但仍然用 $(function() {}) 填充我的 html

标签 javascript jquery html

我依稀记得有人想出了解决这个问题的方法,但我记不住图书馆的名字。基本思想是,通过在页面顶部加载单个小型库,您可以获得在页面底部加载其他脚本的渲染速度优势,同时能够将函数排队以在 DOM 就绪时运行。谢谢

最佳答案

你在想Head JS吗? ?

You’ve read the books and placed SCRIPT SRC tags on the bottom. Good. But can you do this?

// use jQuery on the body of the page even though it is not included yet
head.ready(function() {
   $("#my").jquery_plugin();
});

// load jQuery whenever you wish bottom of the page
head.js("/path/to/jquery.js");

关于javascript - 是否有一个库允许我在页面底部加载 jQuery 但仍然用 $(function() {}) 填充我的 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6157091/

相关文章:

javascript - Rangey如何在没有符号的情况下扩展?

javascript - 如何使用指令添加 css 样式?

jquery - 当轮播中只有 1 张幻灯片时,Owl 轮播仍然会转换

javascript - 在事件监听器中使用绑定(bind)函数

php - Wordpress 单篇文章内容未显示

javascript - 使用本地存储在 2 个样式表之间切换(一次切换)

javascript - Cookiebot Cookie 同意脚本

javascript - 错误未捕获类型错误 : Cannot read property '$' of undefined while getting value of input in section element

html - 如何在内容旁边放置侧边栏?

php - 显示可能通过 HTTP POST (PHP + MySQL) 更改的项目列表的最佳做法是什么