I am trying to debug some code which loads a script with jQuery like this
$.getScript('src/myscript.js', function(){ // start page });
The majority of the time, everything works fine. But some users report intermittent problems with the page not starting. Based on logs I have added to the code, it is clear that for some users, the load callback is never triggered again after they load the page a second time. Clearing their cache removes the problem, but every subsequent reload of the page...it stops again. Other users report intermittent problems, same log results. The user who always has the problem is using Chrome on a Mac.
Anyone had problems like this? I can't find anything in the docs or Googling which would suggest a possible reason..
Related
I'm having a weird problem that I originally just dismissed as a development glitch, but now I'm more concerned because It happens every time I refresh the page.
The issue is when I navigate to another page (localhost:3000/otherpage), sometimes it wont render that page at all. The page will turn completely white and have no HTML elements on the page (according to the dev tools inspector). However If I'm on that page and refresh this will always happen. Theses pages are dynamically rendered pages that have logic written that tells them to load a skeleton page while fetching the data, or render an error page if there's a problem with the request. I'm stumped as to why this is happening and have not been able to find anyone else that has experienced this problem yet.
My question is:
Why does this happen? and how can I work around this?
I have a screen recording to better explain whats going on.
(link to unlisted video):
https://youtu.be/mJPp3P4ElsI
I know my routes are not at issue, and it's probably some js wanting to load but I don't know how to find that js. When I re-route to the home page, and look at the log and then refresh the page, both log entries are exactly the same, (200). Formerly the first iteration would show only an rss feed, but I got rid of that and now it's just blank until I hit the refresh. Happens the same on Opera, Firefox and Chrome.
What's the recommended way to troubleshoot this? Should I remove the scripts one at a time until it works right, or is there a faster way to detect exactly what script is holding things up?
I am having a strange problem i.e., when I am opening my website a loader is loaded and then homepage displays. Now I am navigating from home page to different page, everything is fine . The problem arises when I am getting back to the home page the loader is again loading.
In normal situation it should not load. Not able to find out the reason. I am running the website locally so cant provide the url
window.onload() I have used.
The Window.onLoad() event ALWAYS triggers when the page finishes loading.
http://www.w3schools.com/jsref/event_onload.asp
What is the reason to think that going to your page won't trigger onLoad() the second time? The browser won't know the difference whether it is the first, second, or 500th time.
I have this formula: ({\Delta ^{ - 1}} - T{V_0})
It works perfectly fine when I open the 1st the webpage. As soon as i refresh or open it again, the formula is diplayed in it raw format.
When I remove the browser cache, it work again the next time.
Any idea?
I have tried with Firefox, Chrome.
Thanks.
If you have in-lne configuration, make sure it is before the script tag that loads MathJax.js itself. If it comes after, MathJax may not be able to locate it when it needs it. This can happen when MathJax is in cache, as MathJax can get to the point where it looks for the configuration earlier, and the configuration block might not be available in the DOM yet. So make sure it comes first, as documented.
Thanks for your help Davide, but I figured out what the problem was. In fact, one part of the page was loaded with Ajax, so mathjax was running before the page was loaded. What happened from time to time, is that when I cleared the cache, the ajax page was loaded a bit earlier that the mathjax script, so it worked. What I did is that I reloaded mathjax once the ajax page was loaded and everything works as a charm.
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
I'm using http://instantclick.io which is a jQuery plugin for pjax, however I'm getting some strange problems with my scripts. I've moved bits around so that scripts which did run on $(document).ready(function(){ now run on InstantClick.on('change', function(){ but I still get random problems when I browse through my website.
I was starting to get a feeling that the code is being run more than once, for example when I click on a button, the code it should run was happening more than once. So I stuck this piece of code in my js file just to see what was going on:
$(document).click(function(){
console.log('click');
});
So whenever, I click on anything in the page, I'll get a console log. On initial load of a page, I get the console log once per click. Then when I navigate to a different page, I get two console logs per click, then three logs on the third page I visit etc. So it seems that the InstantClick is caching the js file and running the scripts every time a page is loaded.
I tried putting the data-no-instant attribute on the script tag where the js file is included, but this breaks my code completely.
Hope someone can help!