user2874270
user2874270

Reputation: 1382

IntersectionObserver Polyfill won't load in IE11

I am using IntersectionObserver and have a polyfill that should load if the browser isn't compatible. Unfortunately, things aren't working in IE11. In console, I can see an error that IntersectionObserver is undefined. I'd expect this if I wasn't loading the polyfill, but I should be! I checked the network tab, and it doesn't seem like IE ever downloaded the polyfill script. Any ideas why? Here's my code that should check whether the browser supports IntersectionObserver and loads the polyfill if it doesn't

<script type="text/javascript">
if (!('IntersectionObserver' in window)) {
    var script = document.createElement("script");
    script.src = "https://raw.githubusercontent.com/w3c/IntersectionObserver/master/polyfill/intersection-observer.js";
    document.getElementsByTagName('head')[0].appendChild(script);
}
</script>

Upvotes: 3

Views: 7248

Answers (1)

Deepak-MSFT
Deepak-MSFT

Reputation: 11335

I try to test your code on my side with IE 11 and chrome browser.

I notice that IE 11 downloads the intersection-observer.js file without any issue.

enter image description here

I suggest you to clear the cache and again try to make a test.

you can also try to enable the option Always refresh from server in network tab.

Upvotes: 1

Related Questions