Support for HTML5 `document.currentScript`
See original GitHub issueCan add guaranteed support for HTML’s document.currentScript
in IE 8-10
(but NOT IE 11 😭) by using the techniques from JamesMGreene/document.currentScript.
If it weren’t for the lack of defining getters on DOM interfaces in IE <8
, this can actually be supported all the way down to IE 6
.
I can submit a PR for this soon-ish.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
document.currentScript | Can I use... Support tables for HTML5 ...
"Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.
Read more >Document.currentScript - Web APIs | MDN
The Document.currentScript property returns the <script> element whose script is currently being processed and isn't a JavaScript module.
Read more >Polyfill for HTML5's `document.currentScript`. - GitHub
A polyfill of HTML5's document.currentScript for IE 6-10 ONLY. Public Service Announcement (PSA). This polyfill will not work in IE11 because ...
Read more >How to get document.currentScript.ownerDocument in <script ...
The spec clearly states that when using <script type="module"> the document.currentScript property is set to null during execution.
Read more >Identifying the current `script` element - 2ality
With HTML5 the WhatWG introduced document.currentScript , which this article will use to explain simple techniques to make use of DOM ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi James. Sorry for the delay on this. It’s a tricky one: it is indeed possible to force-include a polyfill in all browsers (and many people do this) using the
always
flag. This is not normally recommended but it makes sense in some cases.So in this case you want to ship a polyfill that depends on defineProperty, but only works in browsers that already have it. if there are any cases where including defineProperty would actually offer any value (e.g. In cases where your polyfill is being force loaded in inappropriate browsers) then I’d agree that on the safe side you should list it as a dependency. However if it makes no difference (your polyfill still fails, and no more or less gracefully) then there’a no benefit to drawing the relationship between the two.
Thanks for fielding that one, Andrew. I’ll proceed to create a corresponding PR when I find the time.