In what seems to be random occurrences, javascript files are not loading.
I believe this diagnosis is correct because a) I have code to check, b) I've stepped through the code, and c) I get “'myfunction' is undefined” error when functions in those files are used.
Sometimes this doesn’t happen for an hour, sometimes it happens every time I load the page, sometimes it happens every other time I load the page. It seems like every time I identify a consistent behavior so I can repeat it and diagnose it, it changes!
Does anybody have any idea what might be causing this?
I'm using :
Right now, it appears to only be happening to my colleague and I on our development environments.
There is one script which appears to be missing more than any other. Here's the script tag.
<script language="javascript"
type="text/javascript"
src="js/Ajax.Utility.js?<%= ConfigurationManager.AppSettings["WebApp.JavaScript.FileVersion"].ToString() %>"></script>
Which evaluates to
<script language="javascript"
type="text/javascript"
src="js/Ajax.Utility.js?090324a"></script>
The version query string parameter doesn't appear to have any effect either since I've both had and not had the problem immediately after changing it.
js and . css files. That is the reason those new changes will not appear to the user. The user either has to clear the browser cookie & reload the page or else he or she has to do a hard refresh of the page by pressing Ctrl+F5.
Most likely, the problem is that you are including your js file in a head tag or somewhere above your main content. By doing this, you are executing your js code before full html content has been attached. As a result, when your js code executes, it does not recognize any html element because there isn't any.
An external JavaScript file must be saved by . js extension. It is recommended to embed all JavaScript files into a single file. It increases the speed of the webpage.
Most browsers seem tolerant to additional commas, e.g. in a definition of a list of object properties:
var obj = {prop1: 'value',
prop2: 'value',};
Internet Explorer is not tolerant to the final comma. Whenever I've had this problem it's ALWAYS proved to be due to an additional comma. Moreover the IE debugger doesn't flag the source problem, it just decries the missing definition(s) from the file that hasn't loaded properly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With