-1

Currently, I am using hls.js in my code to play hls streams. The original code is written in ECMA version 6 and then transpiled into ECMA 5 and places in the dist folder (above link). It works perfectly elsewhere.

I don't plan to use any if the functions from the library. I simply want to include it. Rendering it on IE8 gives errors about the syntax.

Is it possible to transpile the js file into a version compatible with IE8 or I should simply find a way to not include the file at all?

EDIT

Following this I tried doing the following:

<html>
<h1> IE test new </h1>

<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.7/es5-shim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.7/es5-sham.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/json3/3.3.2/json3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.34.2/es6-shim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.34.2/es6-sham.min.js"></script>
<script src="https://wzrd.in/standalone/es7-shim@latest"></script>

<script src="https://cdn.jsdelivr.net/hls.js/latest/hls.js"></script>

</html>

However, it still gives the following error on IE8:

Expected identifier hls.js, line 320 character 31

EDIT 2

I used the following .babelrc file to transpile it to es3 file and fix some other errors.

{
  "presets": ["es3"],
  "plugins": ["transform-es3-property-literals", "transform-es3-member-expression-literals"]
}

However, now I face the following error on IE8.

  Object doesn't support this property or method  hls.js, line 1063 character 17

The specific error is on the line Object.defineProperty. It seems IE 8 does not support the defineProperty method. Is there a way to fix this.`?

kosta
  • 4,302
  • 10
  • 50
  • 104

1 Answers1

0

It looks like old IE has a problem with the property being named default and treats it as a reserved word when used on an object. So to fix the issue you would need to open a ticket with hls and ask them to change it to something different or use it quoted exp['default']

http://jonathonhill.net/2009-11-24/javascript-reserved-words-trigger-expected-identifier-error-on-ie/

But they do state.

Compatibility

hls.js is compatible with browsers supporting MSE with 'video/MP4' inputs. As of today, it is supported on:

Chrome for Android

34+ Chrome for Desktop

34+ Firefox for Android 41+

Firefox for Desktop 42+

IE11+ for Windows 8.1

Safari for Mac 8+ (beta)

I don't know if any transpiler can transpile this into something that is not a problem for old IE. But maybe.

Babel 6.0.20 Modules feature not work in IE8

Community
  • 1
  • 1
Xotic750
  • 22,914
  • 8
  • 57
  • 79
  • Or rather use an ES5-to-ES3 transpiler. They exist (e.g. [for Babel](https://www.npmjs.com/package/babel-preset-es3)). No need to change the library. – Bergi Sep 08 '16 at 10:43
  • I wouldn't expect that they would accept the ticket anyway, as they require Media Source Extensions. I thought that a transpiler would address this old IE issue though, but as I never use one then I could not be sure. :) – Xotic750 Sep 08 '16 at 10:58
  • Nobody cares about old IE, so ES5 output is the default, but most transpilers possess the ability to create ES3 (it's not that hard). – Bergi Sep 08 '16 at 11:01
  • @Bergi tried using Babel ES5-to-ES3 transpiler, However, it gives the same error on IE8. – kosta Sep 09 '16 at 07:29