2

I would like to know if it's possible to pause the page processing till a certain script resource is loaded. But this is the complete picture:

Having many different scripts, some of them loaded using a wrapper and others loaded as just regular scripts like on this HTML:

<script type="text/javascript" src="/path/script1.js"></script>
<script type="text/javascript" src="/path/script2.js"></script>
<script type="text/javascript">wrapper.get('/path/script3.js');</script>
<script type="text/javascript">wrapper.get('/path/script4.js');</script>
<script type="text/javascript" src="/path/script5.js"></script>
<script type="text/javascript" src="/path/script6.js"></script>

The scripts loaded using a wrapper are always downloaded AFTER all the regular scripts are ready. At least this is what I'm experiencing on Firefox 18. The 'get' method of the wrapper does this to download the resources:

jQuery.ajax({
    url: 'url of the script',
    dataType: 'script',
    cache: 'true',
    async: false
});

The above scripts will load in this order:

  1. script1
  2. script2
  3. script5
  4. script6
  5. script3
  6. script4

So I would like to know if there is something I could do in the 'get' method of the wrapper to download them as:

  1. script1
  2. script2
  3. script3
  4. script4
  5. script5
  6. script6

Thanks in advance!

2
  • async: false Your users won't like that... Commented Feb 14, 2013 at 14:47
  • 1
    have a look at this, details how to load Javascript files pragmatically stackoverflow.com/questions/950087/… a little bit of Jquery might be what you need so you can control load order yourself. Commented Feb 14, 2013 at 14:55

1 Answer 1

1

You could wrapper.get be this:

function (url) {
    documen.write('<script type="text/javascript" src="' + url + '"></script>');
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.