Add script after page scroll:

Copy and paste following code into your js file and add your script to addscriptfunc function

   function loadJSFile(file) {
      var jsElement = document.createElement("script");
      jsElement.type = "application/javascript";
      jsElement.src = file;
      jsElement.async = true;
      document.body.appendChild(jsElement);
  }

  var addscript = false;

  function addscriptfunc()
  {
      if (addscriptfunc === true) return;
     
      loadJSFile('http://kkduniya.com/wp-content/plugins/jetpack/modules/widgets/social-icons/social-icons-admin.js?ver=20170506');
      loadJSFile('http://kkduniya.com/wp-content/plugins/elementor/js/jquery.min.js');
      addscript = true;
  }

  function initScript()
  {
      if (addscript === true) return;
       
      if($(window).scrollTop()>1000){
          addscriptfunc();
      }
  }

  document.addEventListener("scroll", function(){
      initScript();
  });

0 Comments

Leave a Comment