question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for HTML5 `document.currentScript`

See original GitHub issue

Can 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:closed
  • Created 7 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
triblondoncommented, Oct 27, 2016

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.

0reactions
JamesMGreenecommented, Oct 28, 2016

Thanks for fielding that one, Andrew. I’ll proceed to create a corresponding PR when I find the time.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found