# 异步载入

  • 将以下代码放入html的head里面
<script>
    (function (para) {
        var p = para.sdk_url, n = para.name, w = window, d = document, s = 'script', x = null, y = null;
        if (typeof (w['sr-sdk-h5']) !== 'undefined') {
            return false;
        }
        w['sr-sdk-h5'] = n;
        w[n] = w[n] || function (a) { return function () { (w[n]._q = w[n]._q || []).push([a, arguments]); } };
        if (!w[n]._t) {
        x = d.createElement(s), y = d.getElementsByTagName(s)[0];
        x.async = 1;
        x.src = p;
        x.setAttribute('charset', 'UTF-8');
        w[n].para = para;
        y.parentNode.insertBefore(x, y);
        }
        })({
        sdk_url: 'https://mp.zhls.qq.com/sdk/sdk-h5/sr-sdk-h5.1.5.1.min.js',
        name: 'SRT',
        server_url: '数据接收地址'
    });
    for (var i = 0; i < 1; i++) {
        setTimeout(() => {
            if (window.SRT) {
                 window.srt = new window.SRT({
                    // SRT初始化之后才能使用
                    token: 'bi72fccc7184efxxxx', // 有数 - ka‘接入测试用’ token
                    /**
                     * 开启打印调试信息, 默认 false
                     */
                    debug: true,
                    autoTrack: true,
                });
                window.srt.setChan({ chan_id: 'xxx' });
                window.srt.track("手动埋点成功了")
            } else {
                i = 0
            }
        }, 1000);
    }
</script>