/    Sign up×
Community /Pin to ProfileBookmark

javascripts not loading properly

In an online application I am working on, several users have been having problems using the app correctly. It seems that not all external javascript files are loaded and thus some of the app functionality is lost. i have been unable to recreate this bug on my own computer, even while running the same software (firefox 2 and vista) as others who have had the bug.

the number of files that load randomly changes each time, so that sometimes the user gets all functionality, and sometimes barely any.

This is how I’m including Javascript:

[CODE]<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″/>
<meta http-equiv=”Content-Language” content=”en-us”>
<link rel=”shortcut icon” href=”images/zIcon.gif”>
<link rel=”stylesheet” type=”text/css” href=”zooplaHome.css” />
<script type=”text/javascript” src=”fileBrowser/shahEncrypt.js”></script>
<script type=”text/javascript” src=”fileBrowser/browserUtils.js”> </script>
<script type=”text/javascript” src=”fileBrowser/tooltip.js”> </script> <!– Tooltip library for helpful messages on action link mouseovers–>
<script type=”text/javascript”> INTERNAL JAVASCRIPT CODES HERE … </script>[/CODE]

Once one of the files doesn’t load, it seems every file that should be loaded after it doesn’t load either. For example, if in this case browserUtils fails to load, then so will tooltip.

this is a very weird bug, and I have been stuck on it for several days. any ideas? are my loading the files wrong?

to post a comment
JavaScript

17 Comments(s)

Copy linkTweet thisAlerts:
@CrazyMerlinMay 27.2007 — a simple check/fix would be to define a variable in each external file (at the end of it), called the name of the file minus the extension, i.e.: var shahEncrypt = true;

before any user-facing code executes to start with, check each of the variables are set with a value of true. Any that are not did not fully load.

if any do not load, based on the name of the variable, reload the file and recheck the variable. If the variable still doesn't come back as true then you know you have an issue inside the file (that's why you set it at the end of the file)

Hope this helps to track down the issue.

//erlin!
Copy linkTweet thisAlerts:
@foid025authorMay 27.2007 — CrazyMerlin,

That sounds like a great idea, and I will try it as soon as I can. Nonetheless, I am worried that it will not help because the erroneous file changes randomly. In other words, every time the page is reloaded, a different number of external files are loaded. Sometimes none are loaded, and sometimes all of them are loaded.
Copy linkTweet thisAlerts:
@FangMay 27.2007 — Sounds like you have a cache problem; serving the same document, but with different linked documents.

http://www.websiteoptimization.com/speed/tweak/cache/

http://www.mnot.net/cache_docs/
Copy linkTweet thisAlerts:
@foid025authorMay 27.2007 — So I would have to tweak the cache in such a way that files are always downloaded fresh?

It seems to me that cache can't be a problem because even when I don't update any of the external scripts and I try reloading the page several times, which files are loaded and which aren't changes. And for the ones that aren't loaded, its as though they weren't found on the server - not that just older copies were kept.

Given this, what do you think?
Copy linkTweet thisAlerts:
@FangMay 27.2007 — Do you reload with (Ctrl) F5?

The browser will look for the document in the cache first and find it there. You're probably reloading the same document unless you force a reload from the server.

Why change the scripts loaded each time? Include all scripts in the document. The initial load will be slightly delayed, but any subsequent (re)load will fetch the scripts from the cache.
Copy linkTweet thisAlerts:
@foid025authorMay 27.2007 — Fang. I thank you for your help with this issue. Unfortunately, I do not quite understand what you mean.

What do you mean by 'Why change the scripts loaded each time?' and 'Include all scripts in the document.' Do you mean the Javascript code should be in the HTML file that is called, as opposed to being in external files?

Here is the situation as I can see it. When, on the computers in which this bug occurs (because for instance I have been unable to reproduce it on my own computer) the page loads, I track which external files are called using the Firebug add on to Firefox. This shows me which external files are called, and which aren't. When the bug occurs, Firebug does not show as many external javascript files being loaded as should be loaded according to the <script> calls I make in the head of the HTML document. As a result, all functions that should be available as a result of those javascript files are not available, and thus return errors when called. When I reload the page, I just press the refresh icon, though I assume Ctrl F5 is the same thing.

If the document was cached properly the first time, then I assume it would be called again the second time and there would be no problem. However, each time I reload the page, a different set of external files is loaded (as far as I can see through Firebug).

Thank you for the time you have spent looking over this, but can you please clarify a little bit. Thanks!
Copy linkTweet thisAlerts:
@FangMay 28.2007 — What do you mean by 'Why change the scripts loaded each time?' and 'Include all scripts in the document.' Do you mean the Javascript code should be in the HTML file that is called, as opposed to being in external files?[/QUOTE][U]All [/U]JavaScript files could be included with every html document.
When I reload the page, I just press the refresh icon, though I assume Ctrl F5 is the same thing.[/QUOTE]The refresh icon loads from cache and the Ctrl F5 reloads from the server.

The only other reason for not loading JavaScript files is if they are server as, for example, text. I believe Fx will not load them, but IE will. You need to find out which browser(s) are having the problem.
Copy linkTweet thisAlerts:
@foid025authorMay 28.2007 — So far, both IE 7 and Firefox are having the problem.

So then, I should include the javascript directly? As in, instead of using <script src="myjsfile"> I should just use <script lang=..> the javascript here</script> ?

Sorry for this misunderstanding. I am just not quite sure what you mean Fang.

On another note, I don't believe it is a browser issue. One person who has been using the app almost constantly has problems, regardless of which browser they use. I on the other hand, have no problem regardless of which browser I use. We are both using the same OS, so I don't see what other configuration difference could be causing the problem.
Copy linkTweet thisAlerts:
@Mr_FerterMay 28.2007 — You must have a or several script errors then if it makes little difference to the type of browser used.
Copy linkTweet thisAlerts:
@foid025authorMay 28.2007 — Yeah that's what I imagine, but then why would it only occur, systematically, on a handful of computers?
Copy linkTweet thisAlerts:
@FangMay 28.2007 — So then, I should include the javascript directly? As in, instead of using <script src="myjsfile"> I should just use <script lang=..> the javascript here</script> ?[/QUOTE]

<script type="text/javascript" src="myjsfile1.js"></script>

<script type="text/javascript" src="myjsfile2.js"></script>

etc.
the number of files that load randomly changes each time,[/QUOTE]Why do this? Load them all. Try this. If it resolves the issue then loading from cache was the problem.

On another note, I don't believe it is a browser issue. One person who has been using the app almost constantly has problems, regardless of which browser they use. I on the other hand, have no problem regardless of which browser I use. We are both using the same OS, so I don't see what other configuration difference could be causing the problem.[/QUOTE]It's not only browsers that have a cache, but some Internet Providers do as well to reduce bandwidth.
Copy linkTweet thisAlerts:
@foid025authorMay 28.2007 — 
Quote:

Originally Posted by foid025

the number of files that load randomly changes each time,

Why do this? Load them all. Try this. If it resolves the issue then loading from cache was the problem. [/QUOTE]


No no - I mean, the number of files that should be loaded remains constant, like they should all always be loaded. But the number that actually IS loaded varies (on these computers where the bug occurs), according to Firebug. Sorry, miscommunication there I think.
Copy linkTweet thisAlerts:
@FangMay 28.2007 — Check your documents for errors and all JavaScript files.
Copy linkTweet thisAlerts:
@Mr_FerterMay 28.2007 — Question: Have you looked at the versions and if the current JScript libraries have been updated or patched, allot of XP machines are still running with the original script engines and have never been updated let alone the .net library installed... you could have a scripting engine difference and some commands are not supported.
Copy linkTweet thisAlerts:
@foid025authorMay 28.2007 — Thanks Fang, I will take a look at the validator and see if there any errors there.

Mr. Ferter, that could be a possibility. Where might I find the version number of the javascript / Jscript libaries? this might help figure out why the bug occurs on some machines and others. Nonetheless, I don't use any advanced commands, except perhaps the AJAX commands to create requests...
Copy linkTweet thisAlerts:
@foid025authorMay 28.2007 — In the Jlint thing, what does this error mean? "variable asdasd declared in a block." As in for example "var asdasd= fileIds[itemCount].firstChild.nodeValue;"
Copy linkTweet thisAlerts:
@FangMay 28.2007 — It's enclosed within parentheses '}', see http://www.jslint.com/lint.html
×

Success!

Help @foid025 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...