Created
May 11, 2016 07:03
-
-
Save daipresents/6111173f20e2a666c7d9d9a050c0938a to your computer and use it in GitHub Desktop.
いいねボタンを非同期読み込みでスピードアップする
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- Facebook Scripts --> | |
| <div id="fb-root"></div> | |
| <script type="text/javascript">// <![CDATA[ | |
| window.fbAsyncInit = function() { | |
| FB.init({ | |
| appId : 'アプリIDをここに書く', // ENTER your FB App ID | |
| channelUrl : 'http://daipresents.com/channel.php', // Channel File | |
| status : true, // check login status | |
| cookie : true, // enable cookies to allow the server to access the session | |
| xfbml : true // parse XFBML | |
| }); | |
| // いいねのトラッキング用 | |
| _ga.trackFacebook(); //Google Analytics tracking | |
| }; | |
| // Load the SDK's source Asynchronously | |
| (function(d, debug){ | |
| var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; | |
| if (d.getElementById(id)) {return;} | |
| js = d.createElement('script'); js.id = id; js.async = true; | |
| js.src = "//connect.facebook.net/ja_JP/all" + (debug ? "/debug" : "") + ".js"; | |
| ref.parentNode.insertBefore(js, ref); | |
| }(document, /*debug*/ false)); | |
| // ]]></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $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 type="text/javascrip" src="/connect.facebook.net/ja_JP/all.js"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment