谷歌分析是否会对下载静态网页的时间产生重大影响?

时间:2022-01-08 15:18:28

I understand that by simply adding a script to the end of the body tag of a html document one makes it processable by Google analytics. My question is, is this likely to have much effect on performance (download time and server load)? Let's assume a static page of say 100k served by IIS. Thanks.

据我所知,只需在html文档的body标记的末尾添加一个脚本,就可以通过Google Analytics进行处理。我的问题是,这可能会对性能(下载时间和服务器负载)产生很大影响吗?我们假设一个由IIS提供的100k的静态页面。谢谢。

15 个解决方案

#1


22  

Will my website's appearance or performance be affected by Google Analytics?

我的网站外观或性能是否会受到Google Analytics的影响?

The appearance of your website will never be affected by your use of Google Analytics - we don't place any images or text on your pages. Likewise, the performance of your pages won't be impacted, with the possible exception of the very first page-load after you have added the tracking code. This first pageview calls the JavaScript on Google's servers, which may take slightly longer than a regular page load. Subsequent pageviews will use cached data and will not be affected.

您使用Google Analytics不会影响您网站的外观 - 我们不会在您的网页上放置任何图片或文字。同样,您的页面性能不会受到影响,可能会在您添加跟踪代码后首次加载页面时例外。第一次网页浏览调用Google服务器上的JavaScript,这可能比常规页面加载时间略长。后续综合浏览量将使用缓存数据,不会受到影响。

It's important to note that many websites on the internet use the same Javascript from the same location on Google's servers, so only rarely will a new user come to your site without already having that file cached locally.

重要的是要注意,互联网上的许多网站使用来自Google服务器上相同位置的相同Javascript,因此,如果没有在本地缓存该文件,新用户很少会访问您的网站。

#2


7  

Yes it does have a performance hit see http://dotnetperls.com/Content/Google-Analytics-Speed.aspx . To speed up its recomended that you download the ga.js file locally and call that instead,Explained here http://www.askapache.com/javascript/google-analytics-speed-tips.html.

是的确有性能影响,请访问http://dotnetperls.com/Content/Google-Analytics-Speed.aspx。为了加快推荐你在本地下载ga.js文件并调用它,请在此处解释http://www.askapache.com/javascript/google-analytics-speed-tips.html。

#3


7  

Edit: Google has released Asynchronous Tracking. I haven't tried it yet, but I guess that it addresses the issues listed below.

编辑:谷歌发布了异步跟踪。我还没有尝试过,但我猜它会解决下面列出的问题。

I think Google Analytics can make a website slower because it does happe that ga.js takes noticably long to load, and this can cause some problems:

我认为Google Analytics可以缩短网站速度,因为ga.js加载的时间非常长,这可能会导致一些问题:

  • If you have a JavaScript that triggers on window.onload (that includes the old school <body onload=""> syntax), then it wont fire until the web page has downloade complety. Using something like jQuery's ready event might remedy this, though.

    如果你有一个在window.onload(包括旧学校语法)上触发的JavaScript,那么它将不会触发,直到网页有下载完成。但是,使用类似jQuery的ready事件可能会解决这个问题。

  • Most browsers do not fill in saved user names and passwords until the web page has loaded completely.

    在网页完全加载之前,大多数浏览器都不会填写已保存的用户名和密码。

  • It is not easy for the average user to spot that a web page is simply waiting for the Analytics script to load, so they might be waiting for the little download animation to finish even though the page has essentially finished downloading.

    普通用户不容易发现网页只是在等待加载Analytics脚本,因此他们可能正在等待小的下载动画完成,即使页面已基本完成下载。

  • You could follow niallbrowne's suggestion of downloading ga.js and serving from your own web server. But this should be a last resort, since ga.js is cached across web sites and only expires once a week.

    您可以按照niallbrowne的建议下载ga.js并从您自己的Web服务器提供服务。但这应该是最后的手段,因为ga.js缓存在网站上,并且每周只过期一次。

#4


6  

Yes.

是。

I feel browsing speed is much better since I added google analytics to addblock filter.

我认为浏览速度要好得多,因为我将谷歌分析添加到了添加块过滤器。

#5


5  

No.

没有。

If you put it at the end it will be loaded last, so even if Googles servers are a bit slow your visitors will never notice.

如果你把它放在最后,它会被最后加载,所以即使Googles服务器有点慢,你的访问者也不会注意到。

ga.js is 9.58k and a logging call is about 1.2k. The js will be cached after the first load (I guess even across sites?) so it's really negligible size wise.

ga.js是9.58k,日志调用大约是1.2k。 js将在第一次加载后缓存(我猜甚至跨站点?)所以它的大小确实可以忽略不计。

#6


2  

Even if you put Analytics code at the bottom of your code, from a users perspective the site hasn't loaded till the little blue bar at the bottom has gone away.

即使您将Google Analytics代码放在代码的底部,从用户的角度来看,该网站尚未加载,直到底部的小蓝条消失。

This means that your site will 'feel' slower, depending on (surprise surprise) how laggy your users connection is. For Dialup users and users accessing your websites from abroad (where request lag is a higher concern) the extra request will definitely mean a slightly less responsive website.

这意味着您的网站会“感觉”变慢,这取决于(惊喜)用户连接的延迟程度。对于从国外访问您的网站的拨号用户和用户(请求滞后是一个更高的问题),额外的请求肯定意味着响应性稍差的网站。

However, given that every image, every javascript file and any other embedded object is an additional request, if you're already using a rich website layout, this is no reason not to use analytics.

但是,考虑到每个图像,每个javascript文件和任何其他嵌入对象都是一个额外的请求,如果您已经使用了丰富的网站布局,则没有理由不使用分析。

#7


1  

The user's experience is definitely slowed down by GA on a slow connection.

GA在慢速连接上的体验肯定会降低。

#8


1  

Remember that not every user has fast US based connections.

请记住,并非每个用户都有快速的美国联系。

If you are on a slow connection from a country outside the US, the difference is certainly noticeable.

如果你与美国以外的国家联系缓慢,那么差异肯定是显而易见的。

People running slower computers or browsers outside the norm (i.e. old versions, mobile phones etc) may all be affected by the javascript execution time.

在规范之外运行较慢的计算机或浏览器的人(即旧版本,移动电话等)可能都受到javascript执行时间的影响。

#9


1  

Sometimes I experience lags in pages that use it. I can track the problem to GA since it's the only script waiting to get loaded. I know this shouldn't happen but with some page requests it does rather randomly. Not that it usually matters since the whole page is already loaded so you can start reading. But it becomes a small problem with pages that use ajax or generaly do stuff on document ready event. So I add it to my adlock filters.

有时我会在使用它的页面中遇到滞后。我可以跟踪GA的问题,因为它是唯一等待加载的脚本。我知道这不应该发生,但有一些页面请求,它相当随机。并不重要,因为整个页面已经加载,所以你可以开始阅读。但是,对于使用ajax或通常在文档就绪事件上执行操作的页面,它会成为一个小问题。所以我将它添加到我的adlock过滤器中。

#10


1  

Take a look at what the competition says.

看看比赛的内容。

#11


0  

Personally I really can't see that there would be much of a difference at all, your browser would cache it after the first request and use it there after on each other page.

就个人而言,我真的看不出会有太大的不同,你的浏览器会在第一次请求后缓存它,然后在每个其他页面上使用它。

The script is loaded at the very bottom of the page as well so everything else should already be loaded.

脚本也会加载到页面的最底部,因此应该已经加载了其他所有内容。

#12


0  

Regarding server load, the scripts are pulled from Google's servers, not yours so there will be no noticeable server side impact. Obviously your pages will all be slightly larger than they were without the code to load the JavaScript, but you'll never notice the difference.

关于服务器负载,脚本是从谷歌的服务器而不是你的服务器中提取的,所以不会对服务器端造成明显的影响。显然,如果没有加载JavaScript的代码,您的页面将会略大,但您永远不会注意到差异。

#13


0  

Note too I've seen GA download a little GIF file with a hash attached to it... but I doubt the size of this will have much of an affect on performance.

请注意,我已经看到GA下载了一个带有散列的小GIF文件......但是我怀疑它的大小会对性能产生很大的影响。

#14


0  

If you add the code to the bottom of the page then it probably won't make much of a difference.

如果您将代码添加到页面底部,那么它可能不会产生太大的影响。

If however, you want it to make no difference then I'd take a look at this link:

但是,如果您希望它没有任何区别,那么我会看一下这个链接:

http://lyncd.com/2009/03/better-google-analytics-javascript/

http://lyncd.com/2009/03/better-google-analytics-javascript/

It describes the approach that Steve Souders took to completely avoid any kind of I/O block.

它描述了Steve Souders完全避免任何I / O块的方法。

#15


0  

Although downloading and running the actual ga.js is fast, what I've noticed all across Europe, on different connections/computers/OSes/browsers, is a MAJOR lag (anywhere from 0 to 30 (thirty) seconds) between the last byte of HTTP request and first byte of HTTP response.

虽然下载和运行实际的ga.js很快,但我在整个欧洲,在不同的连接/计算机/操作系统/浏览器上注意到的是最后一个字节之间的主要延迟(从0到30(30)秒) HTTP请求和HTTP响应的第一个字节。

This is understandable, given the immense popularity of GA, but this is happenning before window.onload fires. So, if your page relies on JS and your users hit this lag, they are not going to analyze which component is responsible - they'll assume your site is horribly slow.

考虑到GA的广泛流行,这是可以理解的,但这是在window.onload引发之前发生的。因此,如果您的页面依赖于JS并且您的用户遇到了这种延迟,他们就不会分析哪个组件负责 - 他们会认为您的网站速度非常慢。

A workaround for this is to register a window.onload function which will add the GA script. Example (using "window.onload=function()" for simplicity):

解决方法是注册一个window.onload函数,该函数将添加GA脚本。示例(为简单起见,使用“window.onload = function()”):

window.onload = function() {
    var gaJsHost = (("https:" == document.location.protocol) 
                      ? "https://ssl." 
                      : "http://www.");
    var s = document.createElement('script');
    s.src = gaJsHost + "google-analytics.com/ga.js";
    s.type='text/javascript';
    var bodies = document.getElementsByTagName('body');
    if (bodies.length > 0) {
        bodies[0].appendChild(s);
    } else { // this should never happen, but sometimes does (curse you IE6!)
        document.appendChild(s);
    }

    // this says 100ms, but won't happen until ga.js is loaded
    window.setTimeout(function(){
        if (window['_gat']) {
            var pageTracker = _gat._getTracker("UA-xxxxxx-x");
            pageTracker._trackPageview();
        }
    },100);
}

#1


22  

Will my website's appearance or performance be affected by Google Analytics?

我的网站外观或性能是否会受到Google Analytics的影响?

The appearance of your website will never be affected by your use of Google Analytics - we don't place any images or text on your pages. Likewise, the performance of your pages won't be impacted, with the possible exception of the very first page-load after you have added the tracking code. This first pageview calls the JavaScript on Google's servers, which may take slightly longer than a regular page load. Subsequent pageviews will use cached data and will not be affected.

您使用Google Analytics不会影响您网站的外观 - 我们不会在您的网页上放置任何图片或文字。同样,您的页面性能不会受到影响,可能会在您添加跟踪代码后首次加载页面时例外。第一次网页浏览调用Google服务器上的JavaScript,这可能比常规页面加载时间略长。后续综合浏览量将使用缓存数据,不会受到影响。

It's important to note that many websites on the internet use the same Javascript from the same location on Google's servers, so only rarely will a new user come to your site without already having that file cached locally.

重要的是要注意,互联网上的许多网站使用来自Google服务器上相同位置的相同Javascript,因此,如果没有在本地缓存该文件,新用户很少会访问您的网站。

#2


7  

Yes it does have a performance hit see http://dotnetperls.com/Content/Google-Analytics-Speed.aspx . To speed up its recomended that you download the ga.js file locally and call that instead,Explained here http://www.askapache.com/javascript/google-analytics-speed-tips.html.

是的确有性能影响,请访问http://dotnetperls.com/Content/Google-Analytics-Speed.aspx。为了加快推荐你在本地下载ga.js文件并调用它,请在此处解释http://www.askapache.com/javascript/google-analytics-speed-tips.html。

#3


7  

Edit: Google has released Asynchronous Tracking. I haven't tried it yet, but I guess that it addresses the issues listed below.

编辑:谷歌发布了异步跟踪。我还没有尝试过,但我猜它会解决下面列出的问题。

I think Google Analytics can make a website slower because it does happe that ga.js takes noticably long to load, and this can cause some problems:

我认为Google Analytics可以缩短网站速度,因为ga.js加载的时间非常长,这可能会导致一些问题:

  • If you have a JavaScript that triggers on window.onload (that includes the old school <body onload=""> syntax), then it wont fire until the web page has downloade complety. Using something like jQuery's ready event might remedy this, though.

    如果你有一个在window.onload(包括旧学校语法)上触发的JavaScript,那么它将不会触发,直到网页有下载完成。但是,使用类似jQuery的ready事件可能会解决这个问题。

  • Most browsers do not fill in saved user names and passwords until the web page has loaded completely.

    在网页完全加载之前,大多数浏览器都不会填写已保存的用户名和密码。

  • It is not easy for the average user to spot that a web page is simply waiting for the Analytics script to load, so they might be waiting for the little download animation to finish even though the page has essentially finished downloading.

    普通用户不容易发现网页只是在等待加载Analytics脚本,因此他们可能正在等待小的下载动画完成,即使页面已基本完成下载。

  • You could follow niallbrowne's suggestion of downloading ga.js and serving from your own web server. But this should be a last resort, since ga.js is cached across web sites and only expires once a week.

    您可以按照niallbrowne的建议下载ga.js并从您自己的Web服务器提供服务。但这应该是最后的手段,因为ga.js缓存在网站上,并且每周只过期一次。

#4


6  

Yes.

是。

I feel browsing speed is much better since I added google analytics to addblock filter.

我认为浏览速度要好得多,因为我将谷歌分析添加到了添加块过滤器。

#5


5  

No.

没有。

If you put it at the end it will be loaded last, so even if Googles servers are a bit slow your visitors will never notice.

如果你把它放在最后,它会被最后加载,所以即使Googles服务器有点慢,你的访问者也不会注意到。

ga.js is 9.58k and a logging call is about 1.2k. The js will be cached after the first load (I guess even across sites?) so it's really negligible size wise.

ga.js是9.58k,日志调用大约是1.2k。 js将在第一次加载后缓存(我猜甚至跨站点?)所以它的大小确实可以忽略不计。

#6


2  

Even if you put Analytics code at the bottom of your code, from a users perspective the site hasn't loaded till the little blue bar at the bottom has gone away.

即使您将Google Analytics代码放在代码的底部,从用户的角度来看,该网站尚未加载,直到底部的小蓝条消失。

This means that your site will 'feel' slower, depending on (surprise surprise) how laggy your users connection is. For Dialup users and users accessing your websites from abroad (where request lag is a higher concern) the extra request will definitely mean a slightly less responsive website.

这意味着您的网站会“感觉”变慢,这取决于(惊喜)用户连接的延迟程度。对于从国外访问您的网站的拨号用户和用户(请求滞后是一个更高的问题),额外的请求肯定意味着响应性稍差的网站。

However, given that every image, every javascript file and any other embedded object is an additional request, if you're already using a rich website layout, this is no reason not to use analytics.

但是,考虑到每个图像,每个javascript文件和任何其他嵌入对象都是一个额外的请求,如果您已经使用了丰富的网站布局,则没有理由不使用分析。

#7


1  

The user's experience is definitely slowed down by GA on a slow connection.

GA在慢速连接上的体验肯定会降低。

#8


1  

Remember that not every user has fast US based connections.

请记住,并非每个用户都有快速的美国联系。

If you are on a slow connection from a country outside the US, the difference is certainly noticeable.

如果你与美国以外的国家联系缓慢,那么差异肯定是显而易见的。

People running slower computers or browsers outside the norm (i.e. old versions, mobile phones etc) may all be affected by the javascript execution time.

在规范之外运行较慢的计算机或浏览器的人(即旧版本,移动电话等)可能都受到javascript执行时间的影响。

#9


1  

Sometimes I experience lags in pages that use it. I can track the problem to GA since it's the only script waiting to get loaded. I know this shouldn't happen but with some page requests it does rather randomly. Not that it usually matters since the whole page is already loaded so you can start reading. But it becomes a small problem with pages that use ajax or generaly do stuff on document ready event. So I add it to my adlock filters.

有时我会在使用它的页面中遇到滞后。我可以跟踪GA的问题,因为它是唯一等待加载的脚本。我知道这不应该发生,但有一些页面请求,它相当随机。并不重要,因为整个页面已经加载,所以你可以开始阅读。但是,对于使用ajax或通常在文档就绪事件上执行操作的页面,它会成为一个小问题。所以我将它添加到我的adlock过滤器中。

#10


1  

Take a look at what the competition says.

看看比赛的内容。

#11


0  

Personally I really can't see that there would be much of a difference at all, your browser would cache it after the first request and use it there after on each other page.

就个人而言,我真的看不出会有太大的不同,你的浏览器会在第一次请求后缓存它,然后在每个其他页面上使用它。

The script is loaded at the very bottom of the page as well so everything else should already be loaded.

脚本也会加载到页面的最底部,因此应该已经加载了其他所有内容。

#12


0  

Regarding server load, the scripts are pulled from Google's servers, not yours so there will be no noticeable server side impact. Obviously your pages will all be slightly larger than they were without the code to load the JavaScript, but you'll never notice the difference.

关于服务器负载,脚本是从谷歌的服务器而不是你的服务器中提取的,所以不会对服务器端造成明显的影响。显然,如果没有加载JavaScript的代码,您的页面将会略大,但您永远不会注意到差异。

#13


0  

Note too I've seen GA download a little GIF file with a hash attached to it... but I doubt the size of this will have much of an affect on performance.

请注意,我已经看到GA下载了一个带有散列的小GIF文件......但是我怀疑它的大小会对性能产生很大的影响。

#14


0  

If you add the code to the bottom of the page then it probably won't make much of a difference.

如果您将代码添加到页面底部,那么它可能不会产生太大的影响。

If however, you want it to make no difference then I'd take a look at this link:

但是,如果您希望它没有任何区别,那么我会看一下这个链接:

http://lyncd.com/2009/03/better-google-analytics-javascript/

http://lyncd.com/2009/03/better-google-analytics-javascript/

It describes the approach that Steve Souders took to completely avoid any kind of I/O block.

它描述了Steve Souders完全避免任何I / O块的方法。

#15


0  

Although downloading and running the actual ga.js is fast, what I've noticed all across Europe, on different connections/computers/OSes/browsers, is a MAJOR lag (anywhere from 0 to 30 (thirty) seconds) between the last byte of HTTP request and first byte of HTTP response.

虽然下载和运行实际的ga.js很快,但我在整个欧洲,在不同的连接/计算机/操作系统/浏览器上注意到的是最后一个字节之间的主要延迟(从0到30(30)秒) HTTP请求和HTTP响应的第一个字节。

This is understandable, given the immense popularity of GA, but this is happenning before window.onload fires. So, if your page relies on JS and your users hit this lag, they are not going to analyze which component is responsible - they'll assume your site is horribly slow.

考虑到GA的广泛流行,这是可以理解的,但这是在window.onload引发之前发生的。因此,如果您的页面依赖于JS并且您的用户遇到了这种延迟,他们就不会分析哪个组件负责 - 他们会认为您的网站速度非常慢。

A workaround for this is to register a window.onload function which will add the GA script. Example (using "window.onload=function()" for simplicity):

解决方法是注册一个window.onload函数,该函数将添加GA脚本。示例(为简单起见,使用“window.onload = function()”):

window.onload = function() {
    var gaJsHost = (("https:" == document.location.protocol) 
                      ? "https://ssl." 
                      : "http://www.");
    var s = document.createElement('script');
    s.src = gaJsHost + "google-analytics.com/ga.js";
    s.type='text/javascript';
    var bodies = document.getElementsByTagName('body');
    if (bodies.length > 0) {
        bodies[0].appendChild(s);
    } else { // this should never happen, but sometimes does (curse you IE6!)
        document.appendChild(s);
    }

    // this says 100ms, but won't happen until ga.js is loaded
    window.setTimeout(function(){
        if (window['_gat']) {
            var pageTracker = _gat._getTracker("UA-xxxxxx-x");
            pageTracker._trackPageview();
        }
    },100);
}