Code2care : TechZone Apps & Tutorials


Twitter button asynchronous loading for your website



You must always load Twitter media buttons on your website asynchronously. If you don't , then it will slow down loading of some important sections of your website.

Note : The code that Twitter provides uses browser-native asynchronous mechanism to load the buttons. But you may use js.async = true; just after like js.src = p + '://platform.twitter.com/widgets.js'; to explicitly load it asynchronously.

<a href="https://twitter.com/share"
   class="twitter-share-button"
   data-url="http://code2care.org"
   data-via="code2care"
   data-size="large"
   data-related="code2care"
   data-hashtags="code2care">
   Tweet
</a>
   
<script>
! function (d, s, id) {
 var js, fjs = d.getElementsByTagName(s)[0],
 p = /^http:/.test(d.location) ? 'http' : 'https';
  if (!d.getElementById(id)) {
  js = d.createElement(s);
  js.id = id;
  js.src = p + '://platform.twitter.com/widgets.js';



  js.async = true;



  fjs.parentNode.insertBefore(js, fjs);
        }
    }(document, 'script', 'twitter-wjs');
</script>


Posts related to twitter.


1. Twitter Introduces translation using Bing for multi-language Support for Tweets

2. Twitter Button Asynchronous Loading for Your Website

3. Share image and text Twitter using your Android Application Programatically

4. Java Code to check if Twitter app is installed on Android device

5. Sharing Multiple Images to Twitter App from your App


Code2care : Lines of Code for Change
Code2care is an initiative to publish and share varied knowledge in technical and non-technical areas gathered during day-to-day learnings and development activities.





Android app on Google Play    








Popular tags
android
x 175
eclipse
x 29
notepadplusplus
x 20
macosx
x 14
sharepoint
x 14
html
x 14
mac
x 13
androidstudio
x 11




1000+ C Programs     PHP Tutorial     JSON Tutorial     Swift Tutorial     India Pinocdes     About Us     Privacy Policy


Code2care © 2012-17