0

I'm using this terrible API for a client. It packages HTML/JS to an iPad app.

I'm using iScroll but it interferes with the built-in scrolling mechanism. They've provided some code to disable their scrolling, but it only works when loaded after all other scripts have loaded (so the API says).

My code structure

<head> 
  <script src="scripts1.js"></script>
  <script src="scripts2.js"></script>
  <script src="scripts3.js"></script>
</head>

<body>
  <script>
  //some page specific code
  </script>
</body>

I'm using some jQuery, but their API is in plain JavaScript. How do I execute their code at the very end? I tried putting it at the end of of the page, but that didn't work. Not sure if using timeout is appropriate?

4

3 回答 3

1

You can use JQuery.getScript and in the success function get other scripts. It should look something like this:

 $.getScript('scriptss1.js', function() {
      $.getScript('scriptss2.js', function() {
            $.getScript('scripts3.js', function() {
           });
     });
 });
于 2012-06-30T15:42:40.237 回答
0

Have you checked out require.js?

于 2012-07-01T02:53:28.983 回答
0

another option would be to add the defer attribute

<script src="scripts1.js" defer="defer"></script>
<script src="scripts2.js" defer="defer"></script>
<script src="scripts3.js" defer="defer"></script>

see http://www.w3.org/html/wg/drafts/html/master/scripting-1.html#attr-script-defer

于 2014-08-08T13:44:32.990 回答