Swiper: Swiper doesn't work in IE11 since release 5.3.0

Created on 28 Feb 2020  路  4Comments  路  Source: nolimits4web/swiper

This is a (multiple allowed):

  • [x] bug
  • [ ] enhancement
  • [ ] feature-discussion (RFC)
  • Swiper Version: 5.3.1
  • Platform/Target and Browser Versions: Windows

Swiper doesn't work in IE11 since 5.3.0. The browser shows a problem with "startsWith" method (or property).

To resolve an error we can use next polyfill:

if (!String.prototype.startsWith) {
        String.prototype.startsWith = function (searchString, position) {
            position = position || 0;
            return this.indexOf(searchString, position) === position;
        };
    }

Most helpful comment

Just for the record, we're compiling TypeScript with webpack and we have a loader.js with the following:

// Typescript loader
const ts = {
  test: /\.(tsx?|jsx?)$/,
  exclude: [
    /node_modules\/(?!(swiper|ssr-window|dom7)\/).*/,
    /.out/,
    /.storybook/,
  ],
  use: [
    {
      loader: 'babel-loader',
      options: {
        configFile: `${__dirname}/babel.config.json`,
      },
    },
  ],
};

This now transpiles the swiper, ssr-window and dom7 modules and swiper is now working in IE11, with the polyfills working too.
We're using the following versions:

    "swiper": "^5.4.2",
    "babel-loader": "^8.0.6",
    "webpack": "^4.42.1",

Note: it took me a while to notice that the 'test' line needed to include .js files as well as .ts files now that we are including certain node_modules, as the rest of our code is .ts files.

  test: /\.(tsx?|jsx?)$/,

All 4 comments

IE 11 is not supported by v5

Thanks! It helped me

@Gachegov59 @nolimits4web is the library still not supported in V5+?

Just for the record, we're compiling TypeScript with webpack and we have a loader.js with the following:

// Typescript loader
const ts = {
  test: /\.(tsx?|jsx?)$/,
  exclude: [
    /node_modules\/(?!(swiper|ssr-window|dom7)\/).*/,
    /.out/,
    /.storybook/,
  ],
  use: [
    {
      loader: 'babel-loader',
      options: {
        configFile: `${__dirname}/babel.config.json`,
      },
    },
  ],
};

This now transpiles the swiper, ssr-window and dom7 modules and swiper is now working in IE11, with the polyfills working too.
We're using the following versions:

    "swiper": "^5.4.2",
    "babel-loader": "^8.0.6",
    "webpack": "^4.42.1",

Note: it took me a while to notice that the 'test' line needed to include .js files as well as .ts files now that we are including certain node_modules, as the rest of our code is .ts files.

  test: /\.(tsx?|jsx?)$/,
Was this page helpful?
0 / 5 - 0 ratings

Related issues

leone510es picture leone510es  路  3Comments

joakimk picture joakimk  路  3Comments

TomDeSmet picture TomDeSmet  路  3Comments

magic-77 picture magic-77  路  3Comments

danielcpereira11 picture danielcpereira11  路  4Comments