开发者

Webkit threading javascript file loadsand execution order

开发者 https://www.devze.com 2022-12-14 09:22 出处:网络
I am trying to building a XSS widget and am having issues with Webkit browsers loading the external javascript files which I am appending into the dom. It works as below:

I am trying to building a XSS widget and am having issues with Webkit browsers loading the external javascript files which I am appending into the dom. It works as below:

  • Widget.js appends 3 javascript files into the dom (jquery, data, content)
  • Jquery.开发者_开发技巧js is standard jquery with a custom namespace
  • Data.js is a javascript array
  • Content.js is a set of jQuery instructions to build the widget based off the data in Data.js

In firefox the browser does exactly 100% of the time what im telling it and the widget loads where ever you placed the include javascript on the page.

However in Webkit ie Safari, the browser returns the 3 files in a random order, and executes once returned. This means that when Content.js looks for $ to do jquery magic it fails. Likewise if jQuery is available and it loads the data late if fails due to lack of data.

Suggestions please?


The best way to do this is to just concatenate the files on the server--that way you go from making 3 http requests to one, and the scripts are parsed and executed together.

If you can't do that, do you have to add the script tags by appending them to the dom? If you just added them in HTML, it should work:

<script src="widget.js"></script>
<script src="jquery.js"></script>
<!--etc -->
0

精彩评论

暂无评论...
验证码 换一张
取 消