title: Best Practices for Loading Mustache.js/ Handlebars.js Templates Cross Domain or CDN
body: <p>This is not really a Mustache.js or Handlebars.js specific question but both frameworks would have this problem if you are trying to optimize the performance loading templates for your web app.</p>
  
  <p>Right now I am loading the templates from the same domain as the rest of the app, but I would like to load my templates from the CDN if possible.  The largest problem with this is that I can't cross browser can't load text files via AJAX.</p>
  
  <p>What other methods can I try to optimize the load time of individual templates cross domain?</p>
  
  <p>I have worked on optimizing the load order <strong>( worked )</strong></p>
  
  <p>loading the templates as xdomain script files in the head <strong>( failed )</strong></p>
  
  <pre><code>&lt;script type='text/html' src="http://domain.cdn.com"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>I think CORs support would be limited to the number of browsers.</p>
  
  <p>Using YQL would be slow.</p>
  
  <p>Can I somehow do what JSONP does, but with an <em>XML</em>, <em>XHTML</em>, or <em>HTML</em>, obviously without the javascript callback?  Maybe the end of the template could have a small callback function, but I wouldn't want to wrap the whole thing and need to escape it as json.</p>