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