kubetail-org / loadjs

A tiny async loader / dependency manager for modern browsers (961 bytes)
MIT License
2.58k stars 151 forks source link

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

Open yourchoice opened 6 years ago

yourchoice commented 6 years ago

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

amorey commented 6 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 6 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 6 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;}
});