title: jquery - how to see if a script with the src of "sub string" already exists in the head tag?
body: <p>I am stumped on this one, never tried this way before but is there a solution to see if a script tag with the source of "x" already exists in the head tag?</p>
  
  <p>Basically I have a site that loads in external plugins. My site loads in jquery into the head tag, and this external plugin also loads the same jquery version into the head tag. I would like to try to run a script that checks the source of all the existing script tags and if their source contains a sub string of "x" to then not load the script tag, else if no script tag with this source exists then to go ahead and load it up.</p>
  
  <p>Here is my use case. </p>
  
  <p>This script tag exists in my head tag </p>
  
  
  
  <p>The external plugin places this script into my head tag</p>
  
  
  
  <p>I would like to edit the plugin to run a check of something like this</p>
  
  <hr>
  
  <p>if $('script[src="in here if this string contains jquery-1.7.1.min.js"]').length; > 0 </p>
  
  <p>then don't load this script into the head tag because its already there;</p>
  
  <p>else load this script into the head tag because it doesn't exist yet;</p>
  
  <hr>
  
  <p>I want to run this kind of check because this plugin can also run on customer web pages were they might not have jquery pre installed on their domains. So thats the rub, I want it to work in both domains. Ones were jquery is installed and ones were its not.</p>
  
  <p>Do you guys have any ideas for this? If I can get this to work I can then use this type of fix for other solutions as well.</p>
  
  <hr>
  
  <p><strong>SOLUTION FOUND</strong>
  I will be using this for now to solve this issue.</p>
  
  <pre><code>if($('script[src$="jquery-1.7.1.min.js"]').length; &gt; 0 ){
      then don't load script
  }else{
      load script because its not on the page yet
  }
  </code></pre>
  
  <p>Going to end up making this a function so I can just pass if JS file urls to see if they are already on the page or not in future projects as well. This is going to be a big help.</p>