Video.js,设置指南,包含全局变量

Video.js, Setup Guide, Include Global Variable

Video.js Setup Guide中,有一条指令允许用户关闭Google分析;但是,我不确定究竟如何按照说明进行操作,并希望确保我这样做是正确的。

指令为:

We include a stripped down Google Analytics pixel that tracks a random percentage (currently 1%) of players loaded from the CDN. This allows us to see (roughly) what browsers are in use in the wild, along with other useful metrics such as OS and device. If you'd like to disable analytics, you can simply include the following global before including Video.js:

window.HELP_IMPROVE_VIDEOJS = false

那个变量去哪儿了?单独的 script 标签?

这是我的:

<head>
    <link href="http://vjs.zencdn.net/5.0.2/video-js.css" rel="stylesheet">
    <script>
        window.HELP_IMPROVE_VIDEOJS = false;
    </script>
    <script src="http://vjs.zencdn.net/5.0.2/video.js"></script>
    <meta charset="ISO-8859-1">
</head>

无法找到 help_imporove_videojs 在 cdn 源中的使用位置... 如果 help_imporove 曾经被使用过

,也许这可以帮助您进行调试
Object.defineProperty(window, "HELP_IMPROVE_VIEDOJS", {
  get: function() { 
    debugger; // trace the call stack
    return false
  }
});

他们还提到了

We include a stripped down Google Analytics pixel that tracks a random percentage (currently 1%) of players loaded from the CDN

所以 1% 的人实际上会帮助改进 videojs。意思是源码99%相同

你得到的是正确的。

如果您查看 CDN 脚本的末尾,最后一部分会检查该变量是否存在并生成一个随机数以确定是否要 ping Google Analytics。