title: How to use jQuery in chrome extension?
body: <p>I am writing a chrome extension. And I want to use <code>jQuery</code> in my extension. I am not using any background <em>page</em>, just a background <em>script</em>.</p>
  
  <p>Here are my files :</p>
  
  <p><code>manifest.json</code></p>
  
  <pre><code>{
      "manifest_version": 2,
  
      "name": "Extension name",
      "description": "This extension does something,",
      "version": "0.1",
  
      "permissions": [
          "activeTab"
      ],
  
      "browser_action": {
          "default_icon": "images/icon_128.png"
      },
  
      "background": {
          "scripts": ["background.js"],
          "persistent": false
      },
  
      "icons": {
          "16": "images/icon_16.png",
          "48": "images/icon_48.png",
          "128": "images/icon_128.png"
      }
  }
  </code></pre>
  
  <p>My <code>background.js</code> file just runs another file named <code>work.js</code></p>
  
  <pre><code>// Respond to the click on extension Icon
  chrome.browserAction.onClicked.addListener(function (tab) {
      chrome.tabs.executeScript({
          file: 'work.js'
      });
  });
  </code></pre>
  
  <p>The main logic of my extension is inside <code>work.js</code>. The contents of which I don't think matters here for this question.</p>
  
  <p>What I want to ask is how can I use jQuery in my extension. Since I am not using any background page. I can't just add jQuery to it. So how can I add and use jQuery into my extension ?</p>
  
  <p>I tried running jQuery along with my work.js from <code>background.js</code> file.</p>
  
  <pre><code>// Respond to the click on extension Icon
  chrome.browserAction.onClicked.addListener(function (tab) {
      chrome.tabs.executeScript({
          file: 'thirdParty/jquery-2.0.3.js'
      });
      chrome.tabs.executeScript({
          file: 'work.js'
      });
  });
  </code></pre>
  
  <p>And it works fine, but I am having the concern whether the scripts added to be executed in this manner are being executed asynchronously. If yes then it can happen that work.js runs even <em>before</em> jQuery (or other libraries which I may add in future).</p>
  
  <p>And I would also like to know what's the correct and best way to use third party libraries, in my chrome extension.</p>