Include files
From Facebook Developers Wiki
We added a new feature to enable referencing FBJS scripts using the src attribute of the <script> tag and the href attribute on <link> tags on canvas pages. This feature is useful for referencing large FBJS and CSS scripts that can be cached on user's browsers.
In order to use this feature, you just need to use regular <script> syntax in HTML. Here is an example:
| <script src="http://foo.com/bar.js"></script> |
When this FBML is rendered into HTML, the src attribute will be changed to point to a Facebook URL that contains a cached FBJS script of the original URL. In addition, the browser caching of this URL is set to never expire so that client browser will cache it as well.
Here are some general guidelines for using this feature:
- The
srcattribute in FBML is enabled only for canvas pages at this time. - Please limit the total number of unique scripts for your application (across all canvas pages) to less than 1000. Facebook may start deleting old scripts if your application uses more than 1000 scripts.
- Please make sure that you don't use a different script URL for each user. For example, http://foo.com/bar.js?user_id=11 and http://foo.com/bar.js?user_id=22 should never be used.
- Since the cache policy is set to never expire, you should update the URL only if the content of the script changes. For example, you can change http://foo.com/bar.js?v=1.0 to http://foo.com/bar.js?v=2.0 or http://foo.com/v1.0/bar.js to http://foo.com/v2.0/bar.js when a new version of the script is available.
- To reduce the number of HTTP requests per page (at least for the first page load) and improve performance, we recommend that you limit your FBJS script references to no more than 10 per page.
- If your script code is small (say a few lines), it's probably better to embed it inline instead of using
src.
Stylesheet Includes
Stylesheet includes are cached automatically by Facebook. Just include a <link rel="stylesheet"> tag like:
| <link rel="stylesheet" type="text/css" media="screen" href="http://yourapp.com/stylesheets/style.css?v=1.0" /> |
Increment the version number upon each change to your style sheet, as specified above.
