Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember CLI deps from CDN?

Loading my ember CLI app currently involved downloading a 3Mb file, most of which consists of common libraries such as jquery, ember, bootstrap, etc. 3Mb is not huge, but it becomes noticable over a slow connection so I want to strip out all the common libraries and get them from a CDN instead. The idea is that they would be cached by the browser to that they don't need to be re-downloaded every time I update my app (which is very often at the moment). I have read this question, which points out that it is easy to simply add a <script...> to index.html, but I can't figure out how to them tell ember not to package those libraries into vendor.js.

like image 393
aquavitae Avatar asked Sep 30 '22 14:09

aquavitae


1 Answers

In brocfile.js (ember-cli-build.js in newer versions) change the constructor to

var app = new EmberApp({
  vendorFiles: {
    'jquery.js': false,
    'handlebars.js': false,
    'ember.js': false
  }
});

Now include those in your index.html the old fashion way and enjoy the fact that pretty much every users browser already has jquery cached even if they haven't visited your site before.

like image 87
AReallyGoodName Avatar answered Oct 03 '22 02:10

AReallyGoodName