Facebook/Google 会导致网站无法加载吗?

发布于 2024-12-14 02:59:42 字数 236 浏览 0 评论 0原文

这听起来可能是一个愚蠢的问题,但昨天我们的网站都无法加载。联系托管公司后,他们说

在这种情况下,您的网站似乎正在挂起,等待外部组件/网站的响应(查看您的代码,我一眼就看到了对 Facebook、Google 和在线应用程序的引用)。

我们以前从未遇到过这个问题,而且这些网站已经使用社交插件几个月了,所以我想知道昨天是否还有其他人遇到过这个问题?

谢谢

This might sound like a silly question, but yesterday none of our sites would load. After contacting the hosting company they said that

In this instance, it would appear that your site is hanging waiting for a response from an external component / website (looking at your code, I see references to Facebook, Google and online apps at a glance).

We've never had this problem before and the sites have been using the social plugins for months so I wondered if anybody else experienced this problem yesterday?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦途 2024-12-21 02:59:42

在不了解详细信息的情况下,我可以告诉您,当您通过 标记加载 Javascript 时,浏览器会等待请求完成,然后再继续。因此,如果您在 部分加载 JS 文件,则在成功加载之前,屏幕上不会呈现任何内容。这里的 404 错误会杀死你,连接速度也会变慢。

如果您有内联 JS,最好将其放在 部分的最底部,这样它就不会中断浏览器渲染。如果您的代码架构允许,请对 部分中的 JS 文件执行此操作。

Without knowing the details, I can tell you that when you load Javascript via <script></script> tags the browser waits for the request to finish before moving on. So, if you load JS files in the <head></head> section, nothing will render on-screen until they load successfully. 404s here will kill you, as will slow connections.

If you have in-line JS, it's best to put it at the very bottom of your <body></body> section so that it does not interrupt browser rendering. Do this for JS files in your <head></head> section if your code architecture allows it.

老子叫无熙 2024-12-21 02:59:42

只是在黑暗中随机刺伤,但我想知道这是否与 Facebook 上的匿名威胁有任何关系。我之前在使用 twitter 插件时也遇到过类似的问题,插件可能需要几秒钟的时间才能 ping 回推文,而当 twitter 正在做他们的事情时,页面的其余部分却挂着。

为了确保这种情况不会再次发生,如果它是可行的解决方案,您可以在页面加载时调用社交插件。归根结底,您是否希望页面加载时间取决于您无法控制的其他服务?

编辑:@Jason McClellan 的答案是正确的。我相信答案的组合可以解决您的问题。如果我不控制资源,我永远不会在头部包含脚本!这可能会无限期地挂起您的页面。

edit2:不知道为什么我对这个答案的评价较低,只是试图将其与我的经历联系起来。我对 Facebook 插件不是很有经验,但是当我注意到我的 twitter 插件有问题时,我完全按照 @Jason McClellan 的回答所说的那样,确保在请求脚本之前渲染所有 html,然后确保页面无论有或没有 Twitter 内容都可以正确显示,因此用户体验不依赖于外部资源。我使用的 Twitter 插件有一个启动函数,我必须调用它来启动脚本。调用它的最简单方法是:

    <body onload='init()'>

类似的内容

    window.onload = function() {
        init();
    }

如果您有另一个脚本正在与页面一起加载,您可以使用外部脚本中

。抱歉,我无法给出特定于 Facebook 插件的答案。也许在 Facebook 插件方面有更多经验的人可以在评论中详细说明:D

edit3:这个基于社区的工具还建议,当您遇到 Facebook 停机时,请安静一些人 - DownRightNow 的 Facebook 状态

edit4:我没有“特权”来评论 Jason 的 q,因为我是新来的……但为了回答你的评论,脑子里的东西您所描述的是 facebook 标记语言 (fbml) 架构中加载的内容,因此是像 html 这样的标记语言,但为您使用 facebook api 做好了准备。因此,您可以执行以下操作:

    <fb:comments xid="titans_comments" canpost="true" candelete="false" returnurl="http://apps.facebook.com/myapp/titans/">
    <fb:title>Talk about the Titans</fb:title>
    </fb:comments>

将一些评论直接添加到您的页面中 - fbml 开发人员指南

您的评论还表明您没有包含供页面加载的脚本,因此它使我们之前的答案不那么重要,您需要在页面中使用 fbml 之前在头部包含 fbml 内容,所以不要移动它:D

但是@jason麦克莱伦的答案是每个人都应该在他们的项目中做的事情(除非有理由不这样做),因为它允许用户在浏览器触发脚本请求之前看到一些东西。归根结底,我们参与这个游戏是为了为我们的用户创造漂亮的东西!

祝你好运

Just a random stab in the dark but I wonder if this was related in any way to the anonymous threats on Facebook. I have experienced similar problems before with a twitter plugin, it could take a few seconds for the plugin to ping back the tweets and the rest of the page was hanging while twitter was doing their thing.

To ensure this doesn't happen again you could call your social plugin's on page load if its a viable solution. At the end of the day do you want your page load time to depend on other services outside of your control or not?

edit: @Jason McClellan 's answer is spot on. I believe the combo of out answers sort out your question. I Never include script in the head if I don't control the resource! That can indefinitely hang your page.

edit2: Don't know why I'm getting down rated for this answer was just trying to relate it to an experience of mine. I'm not extremely experienced with Facebook plugins but when I was noticing an issue with my twitter plugin, I did exactly what @Jason McClellan has said with his answer to make sure that all your html gets rendered before the scripts are even requested, then ensured that the page could display correctly with or without the twitter content so the user experience was not dependant on an external resource. The twitter plugin I was using had an initiation function which I had to call to fire up the script. The simplest way to call this would be with:

    <body onload='init()'>

if you have another script you are loading with the page you could use something along the lines of

    window.onload = function() {
        init();
    }

from within your external script.

Sorry I can't give an answer specific to the Facebook plugin. Maybe someone with more experience in the Facebook plugins could elaborate in the comments :D

edit3: also this community based tool suggests that quiet a few people where seeing a bit of facebook downtime when you experienced it - Facebook status at DownRightNow

edit4: I dont have the "Privelages" to comment on Jason's q as im pretty new here ... but in answer to your comment there, the stuff in the head that you describe is what loads in the schema for facebook mark-up language (fbml) , so a mark-up language like html, but geared up for you to use the facebook api. So you can do stuff like:

    <fb:comments xid="titans_comments" canpost="true" candelete="false" returnurl="http://apps.facebook.com/myapp/titans/">
    <fb:title>Talk about the Titans</fb:title>
    </fb:comments>

To wack some comments straight into your page - fbml developers guide

Your comment there also suggests you are not including a script for your page to load so it renders our previous answers not as important, you need to include the fbml stuff in the head before you use fbml in your page so don't move it :D

but @jason McClellan's answer is something that everyone should do on their project (unless there is a reason not to) as it allows for the user to see something before the browser fires off requests for the scripts. At the end of the day we're in this game to make pretty stuff for our users!

Good luck

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文