Handling code which relies on jQuery before jQuery is loaded

前端 未结 10 1061
挽巷
挽巷 2020-12-08 06:31

I\'d like to follow the general guideline of putting all JavaScript at the very bottom of the page, to speed up loading time and also to take care of some pesky issues with

10条回答
  •  孤街浪徒
    2020-12-08 07:17

    I have this same problem, but with a ton of files, I use headjs to manage the loading, it's only 2kb so there isn't really a problem, for me anyway, of putting in the header. Your code then becomes,

    head.ready(function(){
      $...
    });
    

    and at the bottom of the page,

    head.js('/jquery.min.js');
    

提交回复
热议问题