开发者

loading jquery from code and use document.ready in the page

im trying to load the jquery from the code to prevent double loading of the jquery js file. Just curious how can I do that and still be able to use document.ready to perform operation after开发者_Go百科 document is loaded complete.

thanks


Just load jQuery with a <script> tag. Really.


You can use the HeadJS framework, which does this for you.


<script>
  !window.jQuery && (function() {
    alert("jQuery hasn't loaded");
  })();
</script>

Basically, write everything you want to do if jQuery hasn't loaded inside the anonymous function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜