Get started with 6to5 CDN

MIT licensed

6to5 is a JS transpiler, converting ES6+ code to ES5.

Tags:
  • harmony
  • classes
  • modules
  • let
  • const
  • var
  • es6
  • transpile
  • transpiler
  • 6to5

Stable version

Copied!

How to start using 6to5 CDN


<!DOCTYPE html>
<html>
<head>
    <title>Get started with 6to5 CDN - cdnhub.io</title>
    <script src="https://cdn.cdnhub.io/6to5/3.6.5/browser.js"></script>
</head>
<body>
    <button id="transpile">Transpile ES6 code</button>
    <script type="text/babel">
        const button = document.getElementById('transpile');
        button.addEventListener('click', () => {
            const code = `
                class Counter {
                    constructor() {
                        this.count = 0;
                    }

                    increment() {
                        this.count++;
                        console.log('Count:', this.count);
                    }
                }

                const counter = new Counter();
                counter.increment();
                counter.increment();
            `;

            const result = babel.transformFromAstSync(babel.parse(code), null, { presets: ['@babel/preset-es2015'] }).code;
            console.log('Transpiled code:', result);
        });
    </script>
</body>
</html>
Copied!
Copied!

All versions