Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>This should work:</strong></p> <pre><code>((window, document, requirements, callback) -&gt; getScript = (url, callback) -&gt; script = document.createElement('script') script.src = url head = document.documentElement.childNodes[0] done = false script.onload = script.onreadystatechange = -&gt; if not done and (not (readyState = @readyState) or readyState == 'loaded' or readyState == 'complete') done = true callback() script.onload = script.onreadystatechange = null head.removeChild script head.appendChild script if not ($ = window.jQuery) or requirements['jq'] &gt; $.fn.jquery getScript 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js', -&gt; getScript 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.js', -&gt; callback window.jQuery.noConflict(1) else if not (jqui_version = window.jQuery.ui.version) or requirements['jqui'] &gt; jqui_version getScript 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.js', -&gt; callback window.jQuery.noConflict(1) else callback window.jQuery.noConflict(1) ) window, document, {jq: '1.6.1', jqui: '1.8.7'}, ($) -&gt; # Your code goes here: alert "jq: #{$.fn.jquery}, jqui: #{$.ui.version}" </code></pre> <p><em>You'd want to uncheck the "add jQuery" option on the CoffeeMarklet page to if using the above code</em></p> <p><strong>Update:</strong> Added checking for presence of jQuery and jQuery UI so it isn't loaded unnecessarily.</p> <p><s>Although it could be improved by checking to see if the correct version of jQuery is already present as Ben Almans code does.</s></p> <p><strong>Attribution:</strong></p> <p>Beygi gave <a href="https://stackoverflow.com/questions/6550746/do-something-once-jquery-plugin-has-loaded/6551184#6551184">a lovely snippet</a> for loading javascript resources one after another.</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. 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