Closed jsardev closed 5 years ago
To add custom attributes you can use the before
callback:
loadjs(['/path/to/foo.js', '/path/to/bar.js'], {
success: function() {},
error: function(pathsNotFound) {},
before: function(path, scriptEl) {
/* called for each script node before being embedded */
if (path === '/path/to/foo.js') scriptEl.crossOrigin = true;
}
});
Oh, didn't think about this :D Thanks!
No prob! Happy to help.
It's often needed to pass custom attributes to the
script
tag. It would be great ifloadjs
would support such a usecase.Maybe an
attributes
option would do the work?