Skip to content

Instantly share code, notes, and snippets.

@ivolivares
Last active December 23, 2015 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivolivares/6621414 to your computer and use it in GitHub Desktop.
Save ivolivares/6621414 to your computer and use it in GitHub Desktop.
Multi-Social-SDKs & APIs. Optimiza tu código obteniendo múltiples APIs sin escribir lo mismo 5 veces.
/*
* Nota: Asegúrate de incluir el "_gaq" de Google Analytics y el "fbAsyncInit" de Facebook antes que esta función.
*
* Algo así para Google Analytics:
* window._gaq = [['_setAccount','UA-00000'],['_trackPageview']];
*
* Algo así para Facebook (con apoyo de jQuery):
*
* $(document).ready(function(){
* function facebookReady(){
* FB.init({
* appId : 'LA ID DE TU APP',
* status : true,
* cookie : true,
* xfbml : true
* });
* $(document).trigger("facebook:ready");
* }
* if(window.FB)
* {
* facebookReady();
* } else {
* window.fbAsyncInit = facebookReady;
* }
* });
*/
(function(d, u) {
var s = d.scripts[0],
i = u.length, g;
while (i--) {
g = d.createElement('script');
g.src = '//' + u[i] + '.js';
s.parentNode.insertBefore(g, s);
}
}(document, [
// Google Analytics
'google-analytics.com/ga',
// Google+ button
'apis.google.com/js/plusone',
// Facebook SDK
'connect.facebook.net/es_LA/all',
// Twitter SDK
'platform.twitter.com/widgets',
// LinkedIn SDK
'//platform.linkedin.com/in'
]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment