Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't have a reference for it handy, but script tags are processed in order, and so if you put your <code>$(document).ready(function1)</code> in a script tag after the script tags that define function1, etc., you should be good to go.</p> <pre><code>&lt;script type='text/javascript' src='...'&gt;&lt;/script&gt; &lt;script type='text/javascript' src='...'&gt;&lt;/script&gt; &lt;script type='text/javascript'&gt; $(document).ready(function1); &lt;/script&gt; </code></pre> <p>Of course, another approach would be to ensure that you're using only one script tag, in total, by combining files as part of your build process. (Unless you're loading the other ones from a CDN somewhere.) That will also help improve the perceived speed of your page.</p> <p>EDIT: Just realized that I didn't actually answer your question: <s>I don't think there's a cross-browser event that's fired, no.</s> <em>There is if you work hard enough, see below.</em> You can test for symbols and use setTimeout to reschedule:</p> <pre><code>&lt;script type='text/javascript'&gt; function fireWhenReady() { if (typeof function1 != 'undefined') { function1(); } else { setTimeout(fireWhenReady, 100); } } $(document).ready(fireWhenReady); &lt;/script&gt; </code></pre> <p>...but you shouldn't have to do that if you get your script tag order correct.</p> <hr> <p>Update: You can get load notifications for <code>script</code> elements you add to the page dynamically if you like. To get broad browser support, you have to do two different things, but as a combined technique this works:</p> <pre><code>function loadScript(path, callback) { var done = false; var scr = document.createElement('script'); scr.onload = handleLoad; scr.onreadystatechange = handleReadyStateChange; scr.onerror = handleError; scr.src = path; document.body.appendChild(scr); function handleLoad() { if (!done) { done = true; callback(path, "ok"); } } function handleReadyStateChange() { var state; if (!done) { state = scr.readyState; if (state === "complete") { handleLoad(); } } } function handleError() { if (!done) { done = true; callback(path, "error"); } } } </code></pre> <p>In my experience, error notification (<code>onerror</code>) is not 100% cross-browser reliable. Also note that some browsers will do both mechanisms, hence the <code>done</code> variable to avoid duplicate notifications.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload