Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable async loading and host crosstab on cloudflare/cdnjs #18

Open
tejacques opened this issue Mar 15, 2015 · 0 comments
Open

Enable async loading and host crosstab on cloudflare/cdnjs #18

tejacques opened this issue Mar 15, 2015 · 0 comments
Assignees
Milestone

Comments

@tejacques
Copy link
Owner

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 tejacques added this to the Version 0.3.0 milestone Apr 3, 2015
@tejacques tejacques self-assigned this Apr 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant