A quick, dirty, and evil template for compiling ES6 in the browser.
The Function constructor is a form of eval, and using it is a bad practice.
Also, using Babel in the browser is slow and deprecated.
So, never do this. 😁
xxxxxxxxxx
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.10.3/babel.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
</style>
</head>
<body>
<script>
d3.text('script.js', function(err, source) {
var options = { presets: ['es2015'] };
var compiled = Babel.transform(source, options).code;
(new Function(compiled))();
})
</script>
</body>
https://d3js.org/d3.v4.min.js
https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.10.3/babel.min.js