Prevent jQuery multiple reference

后端 未结 3 2059
时光说笑
时光说笑 2021-01-06 17:45

I am developing DNN modules and I am using jQuery in some modules, I add the jQuery reference to the top of each ascx file, by the way when user add multiple modules to the

3条回答
  •  伪装坚强ぢ
    2021-01-06 18:17

    You could make small script to check if jQuery is present on the page, and only if is not present, load it:

    // 'load-jquery.js'
    window.onload = function () {
      if (window.jQuery === undefined) {
        var script = document.createElement('script');
        script.src = 'path/to/jquery.min.js';
        document.getElementsByTagName('head')[0].appendChild(script); // load jQuery
      }
    };
    

提交回复
热议问题