Open Bug 648908 Opened 10 years ago Updated 2 years ago

external JavaScript file load timing off


(Core :: DOM: Core & HTML, defect, P5)

2.0 Branch
Windows XP





(Reporter: 2ms67q83o001, Unassigned)


User-Agent:       Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; BTRS25104; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322)
Build Identifier: firefox 4.0

The external JavaScript file load timing is off. I load 2 external .js files in the HEAD section and use an OnLoad in the body tag. The files are supposed to be loaded in by the time OnLoad functions run. But they are not. So I ended up hardcoding the JavaScript function into the page in order to get the function to work, which totally defeats the purpose of external .js files. I tested the same page + external .js files in IE and it worked perfectly. You need to make sure external files are 100% LOADED before allowing OnLoad functions to occur.

Reproducible: Always

Steps to Reproduce:
1. Put a couple of external .js file links in HEAD
2. allow OnLoad functions to occur from body tag
3. note that the functions did not work, since they were not loaded
4. In IE 6,7,8 it all works as it should, so it isn't me
Actual Results:  
the functions did not work, since they were not loaded

Expected Results:  
the functions should have worked
Keywords: js1.7
Version: unspecified → 4.0 Branch
Pleased provide a testcase
Component: General → DOM
Product: Firefox → Core
QA Contact: general → general
Version: 4.0 Branch → 2.0 Branch
don, there is in fact code to make sure that external js is loaded before onload fires.  I'd be very interested in a link to the page where you're seeing the issue you're seeing...
Keywords: js1.7
Boris, please don't tease. If you know of a way to make sure that external js is loaded before onload fires, tell me what it is. IE has a way. It's called doing what the W3C JavaScript specs call for: loading in externals before allowing onloads to occur, and it's built into IE. That's why I had no reason to learn code to make it happen-----the browsers are supposed to make it happen. Please send me the commands to ensure that external js is loaded before onload fires!
The reason I cannot show a test case is that I'm a paid programmer who was updating a commercial website that has lots of sales. The owner doesn't want her site to be messed up for a few days while programmers fool with code. I could build a test case except that there is no one to pay for that work---the site owner cannot be expected to. AND I am already deep into my next programming project.
So if you could send me the commands you refer to Boris, it would be very appreciated.
Google searches about the matter lead only to people speculating and guessing about this OnLoad mis-timing. I haven't the time to see if these guesses are BS or not.
If you Boris, are a Firefox programmer, I can't understand why you didn't put this fix into your browser like IE did.

I think you misunderstood something. Boris told you that there is (source) Code in Gecko that should make sure that onload is only fired after external JS files are loaded.
There could be still a bug but that requires a testcase to either find that bug or to point you at the bug in your html/JS.
don, what I said is that I am not aware of any situation in which we fire onload before loading all the scripts.  Onload _always_ waits for all loads to complete.  There are no exceptions.

(On a side note, there is no "W3C JavaScript" spec, nor any spec that defines onload behavior, but you're right that web compat requires that onload wait for all loads... and in Firefox it does.)

Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5.

If you have questions, please contact :mdaly.
Priority: -- → P5
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.