Skip to content
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

JavaScript not loading on IE 11 #5344

Closed
nzambello opened this issue May 9, 2018 · 9 comments
Closed

JavaScript not loading on IE 11 #5344

nzambello opened this issue May 9, 2018 · 9 comments
Labels
type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@nzambello
Copy link

nzambello commented May 9, 2018

Description

On IE11, images are not showing: the base64 placeholder of gatbsy-image do, but the "real" ones don't.
I had no issues using other browsers, this happens only in IE (I tested only in version 11, this is old enough 😉).
I don't have any error in the console.
Inspecting the DOM, I saw there was a <img> element - like in other browsers - with the correct image sizes/resolutions in the <noscript> tag and copying that node in the correct position, beside the base64 image, I get the correct image and everything works fine.

For the moment, I guess I'll do an hack like this on IE, waiting for a solution.

Does anybody had issues like these ones?

Steps to reproduce

I'm using resolutions and sizes in Image components, so I can't find nothing particular in my use case.
It's the basic and common usage of gatsby-image, I followed the docs and Kyle Gill's article.

Environment

  • Gatsby version (npm list gatsby): 1.9.259
  • gatsby-image version (npm list gatsby-image): 1.0.51
  • gatsby-cli version (gatsby --version): 1.1.50
  • Node.js version: 8.1.1
  • Operating System: Ubuntu 16.04.4 LTS / Linux 4.4.0-122-generic

File contents (if changed)

gatsby-config.js:

standard config for gatsby-image and dependencies, as in the docs

package.json:

{
  "name": "",
  "description": "",
  "version": "1.0.0",
  "author": "",
  "dependencies": {
    "@fortawesome/fontawesome": "^1.1.7",
    "@fortawesome/fontawesome-free-solid": "^5.0.12",
    "@fortawesome/fontawesome-pro-regular": "^5.0.12",
    "@fortawesome/react-fontawesome": "^0.0.19",
    "gatsby": "^1.9.259",
    "gatsby-image": "^1.0.51",
    "gatsby-link": "^1.6.44",
    "gatsby-plugin-i18n": "^0.4.2",
    "gatsby-plugin-postcss-sass": "^1.0.20",
    "gatsby-plugin-react-helmet": "^2.0.11",
    "gatsby-plugin-sharp": "^1.6.44",
    "gatsby-source-filesystem": "^1.5.35",
    "gatsby-transformer-sharp": "^1.6.24",
    "intl": "^1.2.5",
    "react-burger-menu": "^2.4.4",
    "react-helmet": "^5.2.0",
    "react-intl": "^2.4.0",
    "react-modal": "^3.4.4",
    "react-tabs": "^2.2.2"
  },
  "keywords": ["gatsby"],
  "license": "MIT",
  "scripts": {
    "build": "rm -rdf .cache/ && gatsby build",
    "develop": "rm -rdf .cache/ && gatsby develop",
    "format": "prettier --write 'src/**/*.js'",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "devDependencies": {
    "autoprefixer": "^8.4.1",
    "postcss-flexbugs-fixes": "^3.3.1",
    "prettier": "^1.12.1"
  }
}
@m-allanson m-allanson added the type: question or discussion Issue discussing or asking a question about Gatsby label May 9, 2018
@nzambello
Copy link
Author

I'm sorry, I didn't see that probably images are not shown because JavaScript is not loaded.
So, IMHO, my problem is caused by IE script handling, as described in #2807.

@thebarty
Copy link

same problem here. any solution?

@nzambello nzambello changed the title Images not showing with gatsby-image on IE 11 JavaScript not loading on IE 11 May 11, 2018
@nzambello
Copy link
Author

nzambello commented May 11, 2018

UPDATE

I tried to solve this issue with an help from #2807.
Now - on IE11 - it's broken due to an issue on Symbol:

I get 'Symbol' is not defined and I guess it comes from gatbsy-plugin-i18n because it's about folktale (a dependecy).

So, I added babel-polyfill in gatsby-browser.js and I'm facing the same issue.

Any help? If adding the polyfill as indicated in #3314 and #2177 (and others) it's still breaking, what could I do?

@fredrik-sogaard
Copy link
Contributor

We fixed it with comment on #2807. PR opened here: #5404

@nzambello
Copy link
Author

@fredrik-sogaard Unfortunately I didn't resolve my problem with your PR #5404. Did you have any suggestion?

Maybe it would work if I'll be able to resolve the Symbol issue. I added the polyfill but I'm still facing this issue.

@fredrik-sogaard
Copy link
Contributor

Have you tried adding https://polyfill.io/v2/docs/ with the default set plus Symbol? Like so
<script src="https://cdn.polyfill.io/v2/polyfill.js?features=default,Symbol"></script>

@nzambello
Copy link
Author

Thank you @fredrik-sogaard!! Now it's working fine, you saved me the day before the golive! 💙

@trickydisco78
Copy link

trickydisco78 commented Nov 12, 2018

I've fixed this by adding gatsby-plugin-polyfill-io to the project. What i want to know is how do i only do this for develop mode as this is all i need it for.

@d3lm
Copy link

d3lm commented Dec 5, 2018

I also had issues with my Gatsby site in IE11 and I was not able to get it up and running. I have tried several solutions suggested in this thread and finally I got it working with polyfill.io. If you experience the same issues and no other solution works then simply add a script tag to the head:

<Helmet>
  <script src="https://cdn.polyfill.io/v2/polyfill.min.js" />
</Helmet>

polyfill.io will read the User-Agent from the browser requesting the script and only include the polyfills you need.

All other solutions did not really work because some Webpack code was executed that uses Array.from which is not available in IE11. The polyfill had to be executed before any other code runs and the only way for me was to add a script tag to the head which is fetched and executed before any other script in the body is executed.

Finally my site runs in IE11 too 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

No branches or pull requests

6 participants