Web app doesn't work when Chrome devtools is closed

I am working on an external web application using JQuery with a lot of Ajax calls. My problem is that whenever the Chrome devtools is closed, the app doesn't work as expected (especially the content added by Ajax). On the other hand, when Chrome devtools is open everything works fine.

I read several similar posts and they were helpful at first, but now I am facing the same problem and I am not sure why.

Note:

1) All Ajax calls are set to cache: false as suggested here .

2) I deleted all console logs as suggested in another post which I can no longer find.

Both suggestions worked temporarily, but now I am where I left off. Any other suggestions as to how Chrome devtools might interfere with Ajax?

+3


source to share


1 answer


So it seems that some JQuery methods (.hover (),. Click (), etc.) are not being applied to some Ajax content, and HTML is loaded when using .load (). I thought I was safe from this problem:

1) Wrapping code that is applied to the Ajax content in the window.onload handler function

2) Delegation of all relevant event handlers

   window.onload = function() {
      $(document).on("click","#id",function(){//do stuff});
      doSomethingElse();
   };

      

After several tries, I ended up using JQuery's .ajaxComplete () method instead of window.onload like this:



        $(document).ajaxComplete(function(event, xhr, settings) {
            if (settings.url.startsWith("https:...[static portion of URI]")) {
                $(document).on("click","#id",function(){//do stuff});
                doSomethingElse();
            }
        });

      

It works. The statement if

here is triggered when the first Ajax call in the section I encountered was called (another chain of Ajax calls from complete () in this first call).

So how does this relate to Chrome devtools?

It turns out this is not directly related. I was able to reproduce the problem in Firefox and Opera. In both Firefox and Opera, the problem was less common, and the developer tools that were open did not have much of an impact on performance. In Chrome, open devtools have made a big difference, and I don't think the problem even occurred once.

0


source







All Articles