Search code examples
javascriptgoogle-chromegeojsonmime-types

GeoJSON file: Refused to execute script from because its MIME type ('') is not executable, and strict MIME type checking is enabled


My web application has a folder named "data" which has .geojson files. When I tried to access my website from Chrome I can see all .geojson files loaded with "200 OK response" Please find below screenshot.

enter image description here

But when I see console logs I am getting "Refused to execute script from because its MIME type ('') is not executable, and strict MIME type checking is enabled."

enter image description here

I have the following code snippet in my HTML file.

enter image description here

Same code working fine in Internet Explorer. I am able to use all .geojson files data from my JavaScript code. Can someone guide me to resolve this issue.


Solution

  • GeoJSON is not a script; it's data, and the type text/javascript is the wrong MIME type for GeoJSON files. If you're loading GeoJSON from other JavaScript code, you should do so in another way rather than using <script> tags in HTML, perhaps through XMLHttpRequest.

    (From comment of mine on Jan. 6, 2020): In any case, Internet Explorer has by now become a legacy product, now that Microsoft has focused its Web browser efforts on Chromium, which is the browser rendering engine behind Google Chrome and recent versions of the Microsoft Edge browser.