Hello, I am looking at using WebKit as an HTML rendering/JS host in a native 
C++ application. Currently the application uses IE via the WebOC. I have WebKit 
running and loading the HTML / JS but I have encountered a problem and I was 
wondering if you could think of any work-arounds.

Problem: The execution order of scripts added to the DOM via insertBefore seems 
to be after scripts statically declared in the HTML file.

I don't have any doubts that WebKit is proper here vis-à-vis the standard 
(though I couldn't find anything specific in the standard that made it clear 
one way or another). Basically what I see is that scripts dynamically injected 
seem to be executed AFTER the statically declared ones, even if inserted before 
them and even if the dynamically injected ones set async to false on the 
created script node.

In IE it seems different. Imagine this scenario, in the root HTML page we have:

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

And assume A.js has JS code that injects another script, let's call it A1, 
(that it dynamically locates, which is why it can't be declared in the markup).

In IE I see this execution order:

A -> A1 -> B

In WebKit I see this execution order

A-> B -> A1

I speculate IE is executing the scripts in the HTML in order and the injection 
done by A is causing the new script to show up and be executed before it gets 
to script B. WebKit on the other hand seems to be enqueing all the scripts from 
the HTML and then executing them in order, so when it hits A and A injects a 
new script it gets placed at the end of the execution queue and executed after 
B.

This is a problem because in our case A1 injects a bunch of global 
functions/properties that B depends on, so if B executes first, well things 
don't go so well.

I could indirect B so it simply did a dynamic injection of its contents like A 
does, call it B1 (I presume that would mean B1 would then be executed after 
A1), but that is non-ideal if there are a lot of scripts involved.

Ryan
_______________________________________________
webkit-help mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-help

Reply via email to