最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Can I host Facebook's all.js locally? - Stack Overflow

programmeradmin2浏览0评论

I've been noticing that sometimes my Facebook app runs slow, and when checked it was because the all.js file was not loaded from the Facebook server, so I copied the file ontp my server and tested it.

Everything seems to work fine, and actually it runs faster. My question is - do you know if there are bugs or errors in doing this?

I've been noticing that sometimes my Facebook app runs slow, and when checked it was because the all.js file was not loaded from the Facebook server, so I copied the file ontp my server and tested it.

Everything seems to work fine, and actually it runs faster. My question is - do you know if there are bugs or errors in doing this?

Share Improve this question edited Mar 16, 2011 at 18:50 Yi Jiang 50.1k16 gold badges138 silver badges136 bronze badges asked Mar 16, 2011 at 18:48 Raul Leaño MartinetRaul Leaño Martinet 2,1136 gold badges29 silver badges44 bronze badges 4
  • 2 pretty sure that's against TOS. also, you don't get updates, etc. also, your host is faster than FB? that's a really nice server you got there then :) – AlfaTeK Commented Mar 16, 2011 at 18:54
  • i dunno if the server runs faster, but it.s obvious that now the app runs faster, maybe because it doesn.t have to search for the file in another server – Raul Leaño Martinet Commented Mar 16, 2011 at 19:08
  • Maybe for you it's faster. But considering that your website will be in a server somewhere in the world, FB has much better world-balancing, world-caching, etc... I'm not sure, but I predict this will be against TOS. – AlfaTeK Commented Mar 16, 2011 at 20:10
  • I'd imagine that it's cached by the end users browser anyway so it's only obtained on first load. And they probably already have it from previous visits to the site. When you load your site check the get requests - what's the code for the .js file the second time round? It's probably 304, not modified and so not (re)loaded. – Paul Collingwood Commented Nov 7, 2012 at 16:38
Add a ment  | 

3 Answers 3

Reset to default 5

The problem here is that now you're shifting a dependency, and by extension the maintenance of that dependency to your local application. If it's hosted on Facebook's servers, they can update it to fix bugs or add features.

If it's taking a long time to load, you should bring it up on their support forums

Your page has to load the all.js file in any case.

  • Facebook servers should be faster than the server which host your website. So, theoretically loading the js file from facebook should be faster.
  • A better approach would be to cache the file for some time. This will make the page loads after the initial one much, much faster.
  • As people have mentioned, the all.js file is updated constantly with bug-fixes etc. So, it is always better to get the newest version of the file instead of manually updating it on your server after some time.

You can have some problems when the facebook update API. You will need to regularly and frequently (every 5 min?) update the file.

发布评论

评论列表(0)

  1. 暂无评论