This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/lib/load-script.js.es6

18 lines
387 B
JavaScript

/* global assetPath */
const _loaded = {};
export default function loadScript(url) {
return new Ember.RSVP.Promise(function(resolve) {
url = Discourse.getURL((assetPath && assetPath(url)) || url);
// If we already loaded this url
if (_loaded[url]) { return resolve(); }
$.getScript(url).then(function() {
_loaded[url] = true;
resolve();
});
});
}