Note that there are some explanatory texts on larger screens.

plurals
  1. POLoading jQuery and jQuery UI in Bookmarklet if they're not already loaded
    primarykey
    data
    text
    <p>I'm working on a bookmarklet which needs access to jquery-ui as well as jquery min. The concern of course being that the page may already have jQuery loaded and conflicts should be avoided.</p> <p>Using Ben Alman's code at found at <a href="http://benalman.com/code/javascript/jquery/jquery.ba-run-code-bookmarklet.js" rel="nofollow noreferrer">http://benalman.com/code/javascript/jquery/jquery.ba-run-code-bookmarklet.js</a> I've been able to gracefully introduce jQuery and hacked in UI to load as well <strong>but there seems to be an issue with the delay</strong> and jQuery UI is not ready to go right away...</p> <p>Is there a better way to handle loading both scripts in sequence before executing the actual code?</p> <pre><code>(function( window, document, jQuery, req_version, callback, callback_orig, parent, script ){ if ( !window[jQuery] || req_version &gt; window[jQuery].fn.jquery ) { parent = document.documentElement.childNodes[0]; script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'; parent.appendChild(script); callback_orig = callback; callback = function($, L) { '$:nomunge, L:nomunge'; $(script).remove(); callback_orig( $, L ); }; } if (typeof jQuery.ui == 'undefined'){ parent = document.documentElement.childNodes[0]; scriptui = document.createElement('script'); scriptui.type = 'text/javascript'; scriptui.src = 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.js'; parent.appendChild(scriptui); alert('Loading your matches...'); } (function loopy($){ '$:nomunge'; // Used by YUI compressor. ( $ = window[jQuery] ) &amp;&amp; req_version &lt;= $.fn.jquery ? callback( parent ? $.noConflict(1) : $, !!parent ) : setTimeout( loopy, 50 ); })(); })( window, document, 'jQuery', '1.3.2', function($,L) { '$:nomunge, L:nomunge'; &lt;all the jquery stuff goes here&gt; </code></pre> <p>There's a similar question at <a href="https://stackoverflow.com/questions/6535641/using-jquery-ui-in-a-bookmarklet">Using jQuery UI in a Bookmarklet</a> with in-depth answers but I have been unable to translate this from CoffeeMarklet to "standard" js.</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.
 

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