title: Call IIFE From Another Javascript File
body: <p>I have a file <code>bg.js</code> whose contents is simply an IIFE. I'd like to load this file/call the function in from another function in another file. Since the IIFE is anonymous (it is, right?) I can't call it by name. It seems I have to load the entire file so it executes immediately.</p>
  
  <p>I've done searching and found many tutorials and documents about what an IIFE is, but nowhere had I seen how to execute one from another scope.</p>
  
  <p>How do I call/load a javascript file that is an IIFE from another javascript file?</p>
  
  <p><strong>More Information</strong>
  The IIFE is loaded in the footer of my page. When I click a link to navigate, the header and footer scripts are not executed. The IIFE in the footer is responsible for setting the background image, so I need to get that function to execute in my <code>perPageBindings()</code></p>
  
  <p>What I think I need to do is invoke the IIFE from another function in the body which is being executed in <code>perPageBindings()</code></p>
  
  <p><strong>Edit for clarity</strong>
  There are two options I am considering:</p>
  
  <ol>
  <li>Simply move the script tag to the body from the footer; or</li>
  <li>Give the IIFE a name so it is no longer anonymous and then call that named function from elsewhere</li>
  </ol>
  
  <p>If 2 is a viable option then I think I will create a new question about converting and IIFE to a named function.</p>