Now my channel.html file looks as follows:
<?php
require_once __DIR__ . '/ay/includes/config.inc.php';
session_set_cookie_params(7200, '/' . AY_PROJECT_ID . '/', 'dev.anuary.com', FALSE, FALSE);
session_start();
$cache_expire = 60*60*24*365;
header("Pragma: public");
header("Cache-Control: max-age=" . $cache_expire);
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $cache_expire) . ' GMT');
?>
<script src="//connect.facebook.net/<?=$_SESSION['ay']['fb']['user']['locale']?>/all.js"></script>
I’d like to reduce it to a plain HTML file serving:
<script src="//connect.facebook.net/en_US/all.js"></script>
Now, the original all.js is included using:
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = 'https://connect.facebook.net/' + ay.locale + '/all.js';
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
ay.locale is variable that changes based on signed request. Does that make any difference?
You should be “safe” to hard-code the JS SDK, as long as it’s still a version hosted by Facebook. It’s not likely that different locales will be out of sync, and the only difference between the different files is user-facing strings.
However, I highly recommend using the same URL instead of hard-coding one locale. The reason for this is that if you use two different URLs, the browser may have to download the SDK twice. The library is big, so that could pose a significant UX problem.
Of course, this is less likely to happen if the user regularly browses other websites that use the en_US SDK and the version in his own locale. If the files are cached, this won’t be an issue.