title: How to call a specific function from a JS file from a Chrome extension
body: <p>I am writing a Chrome extension and i am trying to figure out how i can call a specific function from my <code>script.js</code> file from the <code>background.js</code> file.</p>
  
  <p>So far, my background.js file looks like this</p>
  
  <pre><code>chrome.browserAction.onClicked.addListener(function(tab) {
      chrome.tabs.executeScript(null, {file: "script.js"});
  });
  </code></pre>
  
  <p>Which will run all the js from my <code>script.js</code> file when the user selects the extension icon.</p>
  
  <p>However, i'd like script.js to contain two functions and when the user selects the extension icon, it toggles between each function.</p>
  
  <p>For example, if my <code>script.js</code> file looks like</p>
  
  <pre><code>function makeChanges(){
  
   // some functinality
  
  }
  
  
  function undoChanges(){
  
    // some other functionality 
  
  }
  </code></pre>
  
  <p>how would i specifically get one of the functions to run when the extension icon is clicked? Is this possible using <code>executeSript</code>?</p>