-
-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support "defer" as well as "async"? #92
Comments
Let me think about this some more... in the mean time you can use the loadjs(['/path/to/foo.js', '/path/to/bar.js'], {
success: function() {},
error: function(pathsNotFound) {},
before: function(path, scriptEl) {
scriptEl.setAttribute('defer', 'defer');
}
}); |
Yep - I guess this is a similar request to #84 - if there's an easy way to set those flags innately in the library, would prevent a lot of extra boilerplate needed in consumers. And should hopefully be a tiny change? |
I think something like: { success:function(){}, async: true, defer: false, crossorigin: "anonymous",
importance: "high" } Adding native way to set My real example: <script defer importance="low">
loadjs(
["https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css",
"https://cdn.jsdelivr.net/npm/roboto-fontface-woff@latest/css/roboto/roboto-fontface.min.css"],
{ success:function(){}, async: true, defer: false, crossorigin: "anonymous",
importance: "high" }
);
loadjs(
["https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js",
"https://cdn.jsdelivr.net/combine/npm/short-and-sweet@latest/dist/short-and-sweet.min.js,npm/jquery-vjs-rails@latest/src/rails.min.js,npm/bootstrap@latest/dist/js/bootstrap.bundle.min.js,npm/plyr@latest/dist/plyr.min.js,npm/clipboard@latest/dist/clipboard.min.js,npm/jquery-mask-plugin@latest/dist/jquery.mask.min.js",
"https://cdnjs.cloudflare.com/ajax/libs/vanilla-masker/1.2.0/vanilla-masker.min.js",
"/javascripts/footer.js"],
{ success:function(){}, async: false, defer: true, crossorigin: "anonymous",
importance: "low" }
);
</script> I have some assets do defer and some to load async. Thanks! |
I did some browser testing and found that when you add a |
Thanks!@amorey How about |
Currently, you can add |
It might be nice if this could handle
defer
scripts as well asasync
, as an option.e.g. having a consolidated interface to allow notification either type of scripts being parsed. Would allow
async
scripts to wait ondefer
ones, etc.The text was updated successfully, but these errors were encountered: