Skip to content Skip to sidebar Skip to footer

Why Javascript Files Are Loading Twice Console.log And Alert And Jquery "click" Is Running Twice

why javascript files are loading twice twice? $(window).load(function() { $(function() { console.log('hi'); }); }); this is the console output: both the vm and the

Solution 1:

Your problem is that Categories.js and all other scripts placed in the body are loaded two times, once by the script tag and another time by jQuery using AJAX.

The reason for that is, that you have script tags in the body of your site in combination with the line 118 in scrollingPage.js:

 $('body').wrapInner('<div id="superContainer" />');

jQuery (prior to 1.9) will load and execute the scripts that are wrapped by the newly created div a second time when you call wrapInner.

Possible solutions:

  • update to jQuery 1.9+ if possible
  • move your scripts from body to the head
  • remove them from the body before the code of scrollingPage.js is executed

Solution 2:

$(window).load( function() { console.log('hi'); });

Post a Comment for "Why Javascript Files Are Loading Twice Console.log And Alert And Jquery "click" Is Running Twice"