include.js 456 B

1234567891011121314151617181920212223
  1. export class Include {
  2. init(staticUrl) {
  3. this._staticUrl = staticUrl;
  4. this._included = [];
  5. }
  6. include(script, remote=false) {
  7. if (this._included.indexOf(script) === -1) {
  8. this._included.push(script);
  9. this._include(script, remote);
  10. }
  11. }
  12. _include(script, remote) {
  13. $.ajax({
  14. url: (!remote ? this._staticUrl : '') + script,
  15. cache: true,
  16. dataType: 'script'
  17. });
  18. }
  19. }
  20. export default new Include();