title: Safari Extension: How do you inject content scripts only after a toolbar button is clicked?
body: <p>In my extension, I need to perform actions when the toolbar icon is clicked.  However, there are a lot of scripts and stylesheets involved, so I want to avoid using plain "content scripts", because those are always going to be loaded into every page a user visits, slowing down their browser.  Instead, I want to inject the scripts only after the button is clicked.</p>
  
  <p>The docs only say the following:</p>
  
  <blockquote>
    <p>If you need the command [i.e., a toolbar button click] to initiate an action in an injected script, respond to the command in the global HTML page or an extension bar and send a message to the script.</p>
  </blockquote>
  
  <p>In Chrome, you can use <a href="http://developer.chrome.com/extensions/tabs.html#method-executeScript" rel="nofollow">chrome.tabs.executeScript()</a></p>
  
  <p>In Firefox, you can use <a href="https://addons.mozilla.org/en-US/developers/docs/sdk/1.11/packages/addon-kit/tabs.html#attach%28options%29" rel="nofollow">tabs.activeTab.attach()</a></p>
  
  <p>How do you do it in Safari?</p>