kubetail-org / loadjs

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

Update comments in src to clarify arguments to loadJs #88

Closed asos-tomp closed 5 years ago

asos-tomp commented 5 years ago

The sourcecode indicates that a fourth argument to loadJs is possible, as arg[3]:

https://github.com/muicss/loadjs/blob/master/src/loadjs.js#L216

...however, I'm not sure this is correct, I believe the third argument would be ignored? I think arg[2] could have the comment:

 * @param {Function|Object} [arg2] - The success or error callback or object literal with success/error arguments, numRetries, etc.

...or something more snappy!

Similarly, as per the example:

loadjs(['/path/to/foo.js', '/path/to/bar.js'], {
  success: function() { /* foo.js and bar.js loaded in series */ },
  async: false
});

...arg[1] can actually be an object literal, and not just {(string|Function)} as the comment suggests.

amorey commented 5 years ago

Fixed! Thanks for the suggestion. https://github.com/muicss/loadjs/blob/master/src/loadjs.js#L211-L219