Skip to content

Instantly share code, notes, and snippets.

@imkingdavid
Created November 11, 2013 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imkingdavid/7418331 to your computer and use it in GitHub Desktop.
Save imkingdavid/7418331 to your computer and use it in GitHub Desktop.
<imkingdavid> what's the preferred way of making sure another extension hasn't already loaded jquery ui before I load it?
<nickvergessen> there is a function for it?
<imkingdavid> is that a question or are you telling me there is
<nickvergessen> <script type="text/javascript">window.jQuery || document.
<nickvergessen> similar to this
<nickvergessen> i think there should be
<nickvergessen> if (jQuery.ui) {
<nickvergessen> so try
<nickvergessen> windows.jQuery.ui || ....
<imkingdavid> i have this line: <!-- INCLUDEJS jquery.ui.js -->
<imkingdavid> i want to only call that if jquery ui hasn't been looaded
<imkingdavid> but include is parsed before javascript, right?
<imkingdavid> http://stackoverflow.com/a/14655780/996876
<imkingdavid> i guess that might work
<nickvergessen> just document.write('<!-- INCLUDEJS jquery.ui.js -->')
<nickvergessen> or does this not work?
<imkingdavid> theoretically i'd think it would work, but <script>window.jQuery.ui || document.write('<!-- INCLUDEJS jquery.ui.js -->')</script> shows up in the source as <script>window.jQuery.ui || document.write('')</script>
<imkingdavid> and this shows up beneath it <script type="text/javascript" src="./ext/imkingdavid/prefixed/styles/prosilver/template/jquery.ui.js?assets_version=1"></script>
<imkingdavid> looks like <!-- INCLUDEJS foo.js --> doesn't just return the <script src=""></script> tags, it actually builds an array of scripts to include later
<imkingdavid> or something
<imkingdavid> EX|away: ^^
<prototech> that seems right
<prototech> they're included in the footer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment