How to check support for es 2015, 2016?

I want to generate several variants of js on the site (es5, es2015, es2016), and give the client the necessary file with js, depending on what standard his browser supports. Please tell me how best to check what the client browser supports?

I first wanted to check directly in the browser what it supports, and then connect the necessary js file accordingly. But my concern is whether this will cause js to start executing. later? Just initially, the browser would immediately start loading the file with js, and so it must first reach the code with the check, execute it, and only then add a tag with the script connection and the browser will start loading the desired js.

I thought, maybe such a check can be done on the server, according to the header that comes from the client? I.e., for example, look at the version of the user agent, and understand by it whether this browser supports es2015, or not, maybe there is some php a library for this?

Author: vvtvvtvvt1, 2018-08-08

1 answers

In your case, just make two builds: for IE and for all other browsers. There is a package babel-env, there you can specify a list of browsers for which the bundle is compiled. If you specify new browsers, then babel will not compile everything in es5, but only those things that are not yet supported in the new browsers.

Therefore, you collect it separately for new browsers, separately for IE and send it from the server according to the condition

As an option else, use polyfiles, loading them only for IE, for this conditional comments are suitable:

// если IE9
<!--[if lt IE 9]>
    <script src='ссылка на полифил' >
<![endif]-->
 1
Author: ThisMan, 2018-08-09 08:13:40