简体   繁体   中英

I know how to run js methods when the page finish loading, how can I force certain js to load after everything else?

My project currently uses two different versions of jquery; 1.2.6 and 1.9.0. I use 1.9 only for bootstrap typeahead. It seems in IE8-9, the version somehow reverts back to 1.2.6 even though I used noConflict() when I invoke the typeahead; strangely this only happens on some pages randomly with maybe 10-20% chance of happening.

The typeahead doesnt have to load first/second or whatever, it can load last. Is there a way to force the call to typeahead LAST; ie after pages finish loading and every other js has loaded?

Have u tried $(window).load() instead of $(document).ready(). Another option is update your code that need jquery version of 1.2.6.

Not the most elegant or maintainable solution but simply put the jQuery code at the end of your page. The order in which you call $(document).ready() is the order it is executed, so:

<head>
  <script ...>
    $(function(){ ... called first ... });
  </script>
</head>
<body>
  ...
  <script ...>
    $(function(){ ... called last ... });
  </script>
</body>

As mentioned rather migrate to 1 version of jQuery!

We've had similar issue and what I've done is created new master page for new version of jquery.

After a while when there was more time we've upgraded whole project to newest version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM