-
Notifications
You must be signed in to change notification settings - Fork 4
Assign attrs to created script element #3
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
Assign attrs to created script element #3
Conversation
var doc = document | ||
var tag = 'script' | ||
var firstScript | ||
var el | ||
el = doc.createElement(tag) | ||
firstScript = doc.getElementsByTagName(tag)[0] | ||
if (attrs) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Placement is important here—we want to control & possibly overwrite async
, src
, onload
, etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you make attrs = {}
by default and then just simply (with no conditional):
Object.assign(el, attrs);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep in mind that we're not using babel here, so let's keep compatibility to IE11.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
carry on!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah im trying to keep it old school in this PR.
var doc = document | ||
var tag = 'script' | ||
var firstScript | ||
var el | ||
return new Promise(function (resolve, reject) { | ||
el = doc.createElement(tag) | ||
firstScript = doc.getElementsByTagName(tag)[0] | ||
if (attrs) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto for above
f4ba9fb
to
2556a05
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Need this feature to allow optional
crossOrigin
on behance. However, might be nice for any user of this package to define arbitrary properties on<script />
.