crosstab icon indicating copy to clipboard operation
crosstab copied to clipboard

Enable async loading and host crosstab on cloudflare/cdnjs

Open tejacques opened this issue 10 years ago • 0 comments

This is a pretty simple addition and can be done similarly to how analytics and gpt work.

Loading Tag

<script>
    (function (window, document, script, url, crosstab, scriptTag, firstScriptTag) {
        window[crosstab] = window[crosstab] || (function (fn) {
            (window[crosstab].q = window[crosstab].q || []).push(fn);
        })();
        scriptTag = document.createElement(script);
        scriptTag.async = true;
        scriptTag.src = url;
        firstScriptTag = document.getElementsByTagName(script)[0];
        firstScriptTag.parentNode.insertBefore(scriptTag, firstScriptTag);
    })(window, document, 'script', '//url.to/crosstab.js', 'crosstab');
</script>

This minifies to the following:(this is beautified to be readable but get the point across)

(function(w, d, s, u, c, n, r) {
    w[c] = w[c] || function(f) {
        (w[c].q = w[c].q || []).push(f)
    }(),
    t = d.createElement(s),
    t.async = !0,
    t.src = u,
    r = d.getElementsByTagName(s)[0],
    r.parentNode.insertBefore(t, r)
})(window, document, 'script', '//url.to/crosstab.js', 'crosstab');

Change to crosstab.js

When crosstab is setting up, it should look for a global crosstab variable, and try to grab the cmds out of it. If present, it should call crosstab(fn) for each one.

This isn't a critical feature, but it's nice to have

tejacques avatar Mar 15 '15 19:03 tejacques