JSFiddle - React, Tailwind, and code Playground

by tylermwashburn

HTML

<p id="output"></p>

JavaScript

var Require = function (name, callback) {
    var prefix = ";(function (exports) { \"use strict\";",
        suffix = "}).call(this, this);",
        xhr = new XMLHttpRequest(),
        exports = {},
        url, i;

    // There's usually some code here to turn the name into a url.
    url = name;

    xhr.open("POST", url, true);

    xhr.onload = function () {
        if (xhr.status < 400) {
            Function("global", prefix + xhr.responseText + suffix).call(exports, window);
        }
        
        callback(exports);
    };

    xhr.send('xml=' + escape('exports.hi = "Hey"'));

    return exports;
};

Require('/echo/xml/', function (something) {
    $('output').update(something.hi);
});