kubetail-org / loadjs

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

Bundle ids in dependency lists are not working #61

Closed Craz-z-zy closed 6 years ago

Craz-z-zy commented 6 years ago

Bundle ids in dependency lists are not working (example number 7). Bundle id in dependency list detects like a script. In the browser's console it shows as script not loaded (status 500). Loadjs calls error callback.

amorey commented 6 years ago

Can you share your code so I can see what the issue is? Here's an example that uses bundle ids in dependency lists: https://jsfiddle.net/muicss/ts5fv67L/

Craz-z-zy commented 6 years ago

https://codepen.io/txid/pen/pLRqYx - copy of code https://jsfiddle.net/muicss/ts5fv67L/ with some changes. But it's different with my situation. And this is situation at my local server: loadjs

amorey commented 6 years ago

Thanks for sharing your code. I took a closer look at the JSFiddle and it works because JSFiddle doesn't return a 404 Not Found when you access a file/subdirectory that doesn't exist. As you described, there is an error in the documentation. This is the proper way to express the dependencies in the example:

loadjs(['/foo1.js', '/foo2.js'], 'foo');
loadjs('/bar.js', 'bar');

loadjs.ready(['foo', 'bar'], {
  success: function() {alert("foobar");},
  error: function (notFound) {console.log("Not found: " + notFound);}
});

I'll update the documentation shortly.

cc @uptimestar

Craz-z-zy commented 6 years ago

The code base is your's. I have only used browser console to debug code, that doesn't worked. Online web developing tools gives different results. But where were not result the same as my.

Thank you. I have solved my problem the next way:

loadjs(['/some_library.js', '/extension_for_some_library.js'], 'some', { async: false });
loadjs(['/my_script.js'], 'mylib');
loadjs.ready(['some', 'mylib'], {
       success: function() { alert("success"); },
       error: function(notFound) { alert("Not found: " + notFound); }
});