kubetail-org / loadjs

A tiny async loader / dependency manager for modern browsers (899 bytes)
MIT License
2.57k stars 149 forks source link

Add .path() method like on $script.path() #77

Open yourchoice opened 5 years ago

yourchoice commented 5 years ago

Add .path() method like on $script.path()

amorey commented 5 years ago

I can see how this would be useful but you can already do this by prefixing the paths yourself (you can also use a before callback function). I'm curious to see how many other people have this problem. Unless it's a common issue, my preference is for keeping the LoadJS feature set to an absolute minimum.

yourchoice commented 5 years ago

I say in idea if there are many files to load in same path to reduce the code:

loadjs(['foo.js', 'bar.js'], 'foobar', { 'path_prefix': '/path/to/' });

amorey commented 5 years ago

If you'd like to start doing this now you can use the before callback:

loadjs(['foo.js', 'bar.js'], 'foobar', {
  before: function(path, scriptEl) {scriptEl.src = '/path/to/' + path;}
});