Advertisement
tweenpix

lazy load js by jquery

Jan 17th, 2022
704
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.            
  2.     jQuery(document).ready(function () {
  3.       jQuery.cachedScript = function (url, options) {
  4.         options = $.extend(options || {}, {
  5.           dataType: "script",
  6.           cache: true,
  7.           url: url,
  8.         });
  9.         return jQuery.ajax(options);
  10.       };
  11.       console.log($(location).attr("href"));
  12.    
  13.       $(document).one("scroll", function (event) {
  14.         console.log('bitrix loading...');
  15.         window.setTimeout(function () {
  16.             $.cachedScript(
  17.             "https://cdn.bitrix24.ua/crm/site_button/loader_1_ojfniz.js"
  18.             ).done(function (script, textStatus) {
  19.             console.log("bitrix is " + textStatus);
  20.             });
  21.           }, 7000);
  22.    
  23.       });
  24.    
  25.     });
  26.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement