Open Bug 730760 Opened 11 years ago Updated 11 years ago

laying out and rendering shouldn't halt by <script> accessing another server for src attribute

Categories

(Core :: Layout, defect)

x86_64
Windows 7
defect
Not set
normal

Tracking

()

UNCONFIRMED

People

(Reporter: masayuki, Unassigned)

Details

I confirmed this problem on latest Nightly on Win7, but I'm not sure whether similar bug was reported already.

Load http://blog.graffiti-web.org/archives/2006/04/wmode.html

Then, Firefox tries connecting blogbattler.com. (I can see "connecting to blogbattler.com..." message.) Maybe, response of the server is too slow. I can see only the page's head and a small square in right side of the page at that time.

After that, the remaining contents will be laid out and rendered.

For the user experience, Gecko should lay out and render the remaining contents during accessing the server.
And I've sometimes experienced similar issue on other web pages when they have some ads.
The relevant bit is this tag right at the front of the <body>:

<script id="blogbattler" type="text/javascript" src="http://blogbattler.com/js/blogbattler.js#2"></script>

We can't do layout of anything that comes after the script until after it loads, because it can document.write things that will completely change the token stream...  Think:

  document.write("<!--");

in the script.

If the page doesn't want the script to block rendering, that's what @async and @defer are for, of course.
Obviously, I'd love to know how we can avoid just WONTFIXing this, by the way; I just don't see a way to do it without seriously breaking web compat.
(In reply to Boris Zbarsky (:bz) from comment #2)
> We can't do layout of anything that comes after the script until after it
> loads, because it can document.write things that will completely change the
> token stream...  Think:
> 
>   document.write("<!--");
> 
> in the script.

Indeed... If it's not <script>, e.g., <object> or <img>, this problem doesn't happen?
This behavior only happens for <script> and <link rel="stylesheet">, and for the latter only in some situations.
Just an idea: When connecting is too slow, rendering engine should block all scripts until finishing the loading. And if the script used document.write() or something, retry parsing and rendering from first.

If so, I guess that it improves the UX in many cases.

But I think such big hack doesn't make sense...
Summary: laying out and rendering shouldn't halt by accessing another server → laying out and rendering shouldn't halt by <script> accessing another server for src attribute
You need to log in before you can comment on or make changes to this bug.