Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #22194

Re: onload and order

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!fx19.iad.POSTED!not-for-mail
Content-Type text/plain; charset=utf-8; format=flowed; delsp=yes
Newsgroups comp.lang.javascript
Subject Re: onload and order
References <D-adnXLr779cjAjPnZ2dnUVZ_vmdnZ2d@westnet.com.au>
MIME-Version 1.0
Content-Transfer-Encoding 7bit
From Archenoth <Archenoth@live.something>
Message-ID <op.w66x88q8bm00eh@hathor> (permalink)
User-Agent Opera Mail/12.16 (Linux)
Lines 39
NNTP-Posting-Host 96.51.223.95
X-Complaints-To internet.abuse@sjrb.ca
X-Trace 1385531249 96.51.223.95 (Wed, 27 Nov 2013 05:47:29 UTC)
NNTP-Posting-Date Wed, 27 Nov 2013 05:47:29 UTC
Date Tue, 26 Nov 2013 22:47:22 -0600
X-Received-Bytes 1721
X-Received-Body-CRC 2416033162
Xref csiph.com comp.lang.javascript:22194

Show key headers only | View raw


On Tue, 26 Nov 2013 15:24:09 -0600, Andrew Poulos <ap_prog@hotmail.com>  
wrote:

> I have a page laid out like this
>
> <!DOCTYPE html>
> <html>
> <head>
> ...
> <script type="text/javascript" src="scripts/a.js"></script>
> ...
> </head>
> <body>
> ...
> <script type="text/javascript">
>    // b
> </script>
> ...
> </body>
> </html>
>
> "a.js" has a window.onload
>
> Interestingly Chrome and Opera run the code at "b" after the onload is  
> triggered but only if the page is on a web server. If the page is on my  
> local file system the code at "b" runs first.
>
> Andrew Poulos

script tags are run as they are read, I believe the variation is just a  
matter of file:// (local) reading faster than http:// (downloaded).

window.onload = function(){}; will execute when the entire page is loaded.  
That very well might be enough time for the code in the script tags at "b"  
to run, with a higher likelihood to run first the longer it takes to  
download a.js.

-- 
The arch foe

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

onload and order Andrew Poulos <ap_prog@hotmail.com> - 2013-11-27 08:24 +1100
  Re: onload and order Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-26 23:06 +0100
    Re: onload and order Andrew Poulos <ap_prog@hotmail.com> - 2013-11-27 10:15 +1100
      Re: onload and order Andrew Poulos <ap_prog@hotmail.com> - 2013-11-27 11:35 +1100
        Re: onload and order Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-27 01:39 +0100
  Re: onload and order Archenoth <Archenoth@live.something> - 2013-11-26 22:47 -0600
  Re: onload and order John Harris <niam@jghnorth.org.uk.invalid> - 2013-11-27 15:18 +0000
    Re: onload and order Andrew Poulos <ap_prog@hotmail.com> - 2013-11-28 09:44 +1100

csiph-web