ocombe / ocLazyLoad

Lazy load modules & components in AngularJS
https://oclazyload.readme.io
MIT License
2.63k stars 510 forks source link

added easy cdn prefix configuration #428

Closed gchamon closed 4 years ago

gchamon commented 6 years ago

By default, ocLazyLoad loads all dependencies directly from the paths provided. If, however, the user intends to use a cdn like Amazon's Cloudfront to serve static files, he must provide the full address in every path. With this simple implementation, you can easily configure the ocLazyLoad to inject prefixes in every path, like this:

angular.module('myModule').config([
  '$ocLazyLoadProvider',
  ($ocLazyLoadProvider) => $ocLazyLoadProvider.config({"cdn": "https://mycdn.com/"})
]);
$ocLazyLoad.load('/assets/dependency.js')

resulting html:

<html>
<body>
<!-- ... -->
<script src="https://mycdn.com/assets/dependency.js">
<!-- ... -->
</html>
</body>
darraghenright commented 2 years ago

Hi @gchamon — ah this would have been very useful as the use case you describe is exactly what I am trying to do — load assets from Cloudfront. Did you close this because there were no responses?

gchamon commented 2 years ago

Hi @gchamon — ah this would have been very useful as the use case you describe is exactly what I am trying to do — load assets from Cloudfront. Did you close this because there were no responses?

I closed it a while ago, but I believe it was because of lack of response, yes. The pull request should work. This project seem defunct, as no updates since 2017 were issued. Do you know any repository that is still maintained?

darraghenright commented 2 years ago

Hi @gchamon — yeah, I checked it out yesterday and it worked a treat. Unfortunately there were unrelated reasons stopping me from serving assets from Cloudfront right now so I abandoned that approach, but hopefully I'll get that working at some stage in the future. So yeah, I know there's a drop in that will help me there — thanks a million for that!