title: Using jQuery / javascript How to check if JS file ( SP.JS) is already called in a page?
body: <p>I want to check if a particular JS file is already loaded in document.ready.</p>
  
  <p>Something like this: </p>
  
  <pre><code>if(file already called/loaded) { // my code }
  else {//some other code}
  </code></pre>
  
  <p>The JS File is not any plugin.</p>
  
  <p>Its basically a JS file related to SharePoint like Sp.JS. </p>
  
  <p>We just know the file name. </p>
  
  <p>[Update - Added the code ]</p>
  
  <p>I have added the below code and it throws an error in console : SP.Runtime.js is already loaded.</p>
  
  <p>If I remove the loading of SP.Runtime.js my code doesnt work in some pages where Runtime.Js is not loaded by default.</p>
  
  <pre><code>$(document).ready(function() {
      var scriptbase = _spPageContextInfo.webServerRelativeUrl + "/_layouts/15/";
      $.getScript(scriptbase + "init.js",
      function() {
          $.getScript(scriptbase + "SP.Runtime.js",
          function() {
              $.getScript(scriptbase + "SP.js",
              function() {
                      $.getScript(scriptbase + "SP.Taxonomy.js",
                      function() {
                          context = SP.ClientContext.get_current();
                         // My custom function //
  
                      });
              });
      });
      });
  });
  </code></pre>
  
  <p>Please suggest.</p>
  
  <p>Thanks</p>