将jQuery lib动态地包含到页面中的最轻量级方法是什么?我正在一个页面上工作,有时它运行一些自定义脚本(10行),有时也需要整个jquery.
ujh*_*ujh 10
只需在需要时为jQuery添加脚本标记:
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'http://www.example.com/jquery.js';
document.body.appendChild(script);
Run Code Online (Sandbox Code Playgroud)