compact icon indicating copy to clipboard operation
compact copied to clipboard

Third-party scripts (Feature)

Open bengourley opened this issue 12 years ago • 1 comments

It would be nice to have a feature in compact that lets you reference third party scripts.. e.g jQuery on Google's CDN, Google Maps API, various share widgets (Twitter, +1, Facebook).

e.g:

compact.addNamespace('find-us')
    .addThirdPartyJs('http://maps.google.com/maps/api/js?sensor=true')
    .addJs('/js/my-map.js');

Output:

<script src='http://maps.google.com/maps/api/js?sensor=true'></script>
<script src="/js/compact/find-us.js"></script>

Similar functionality is easily achievable with Jade template inheritance, but I think it would be better if all of the frontend JS was organised in one place. What do you think?

bengourley avatar Mar 22 '12 20:03 bengourley

I think that addJs could be extended to take urls to compress.

But I'm a not sure about of making compact a javascript loader. Either I need to change the name to a synonym of 'Load' or we create another module that extends compress and but helps manage all your JavaScript.


jsLoader.addRemoteNamespace('map')
    .addJs('http://maps.google.com/maps/api/js?sensor=true', { failoverToLocal: true })

jsLoader.addNamespace('find-us')
    .addJs('/js/my-map.js');

serby avatar Mar 23 '12 12:03 serby