title: Creating crawlable cross domain javascript widgets
body: <p>I have been reading about making ajax heavy applications more search engine friendly: 
  <a href="https://developers.google.com/webmasters/ajax-crawling/docs/getting-started" rel="nofollow">https://developers.google.com/webmasters/ajax-crawling/docs/getting-started</a></p>
  
  <p>One of the solutions I have delivered recently relies heavily upon cross domain javascript widgets. A website that integrates this solution would include a piece of javascript in their website. For example:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
    var _lw = _lw || {};
    _lw._setAccount = ' 00000000-0000-0000-0000-000000000000' ;
    _lw._widgetType = '_widgetName';
    _lw._options = {};  
  
    (function() {
      var scriptsrc = document.createElement('script'); 
      scriptsrc.type = 'text/javascript'; 
      scriptsrc.async = true;
      scriptsrc.src = 'http://hostname/Application/js';
  
      var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(scriptsrc, s);
    })();
  &lt;/script&gt;]
  
  &lt;div id="widget-container"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>This request appends to the dom a jQuery wrapper along with relevant application URL's that the widget will use. Note, the source of this piece of javascript is simply an asp.net mvc content result which outputs the relevant content:</p>
  
  <pre><code>[HttpGet]
  [ActionName("js")]
  public ContentResult RenderJavascript()
  {
        // java script urls &amp; jquery wrapper are output
  }
  </code></pre>
  
  <p>Now that the necessary url's are available, the jQuery wrapper that was just appended kicks in and fires off a request to the server with the account information, the widget type and any relevant options. <code>ASP.net MVC</code> is simply acting as a content generator and it returns a <code>JSONP</code> result where the generated content is appended into the sites content container.</p>
  
  <pre><code>function loadWidget() {
      var jsonpUrl = _opts._widgetUrl + _lw._setAccount;
      jQuery.getJSON(jsonpUrl, _lw._options, function (data) {
          jQuery('#widget-container').html(data.html);
      });
  }
  </code></pre>
  
  <p>The more I read on making this process more search engine friendly I'm at a loss of where to start. Generating the required HTML snapshot is easy enough however, <strong>how would I signify to google that a link should be crawled</strong>?</p>
  
  <p>Another option that seemed somewhat promising was the section on how to handle pages without hash fragments. This would be accomplished by adding a meta tag that is making use of the javascript widgets. </p>
  
  <pre><code>&lt;meta name="fragment" content="!"&gt;
  </code></pre>
  
  <p>However, the problem now is in the fact that this is a cross domain request and again wont' lead anywhere.</p>