StudioPress Community Forums
  StudioPress Community Forums > Forums > General Discussion
For help and support, access to your downloads, or to manage your account please log into My StudioPress.

These forums have been set to read-only so you can browse the existing topics for any questions you may have -- and this forum will be removed on July 1st, 2013.

For general discussion on WordPress, CSS and design (NOT for support) visit the new Community Forums.
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-12-2012, 08:33 AM
noxbane noxbane is offline
Registered User
Pro Plus Member
 
Join Date: Nov 2010
Posts: 139
Default Social Buttons On Every Post - Slows Page Load

I've added social media action buttons (Facebook, Twitter, Google+, Pinterest) to the bottom of every post excerpt on the home and archive pages. It works decently on my development server but when I tried moving it to the live server the page load time was awful.

Development Server Link: http://durban.directrouter.com/~babyname/blog/ - This is a custom child theme.

Am I doing this in a terribly inefficient way or somethng? Here is how I add them via functions.php


Code:
/* add social action buttons below content on home page */
add_action('genesis_meta', 'child_display_post_social_action_buttons_helper');

function child_display_post_social_action_buttons_helper () {
	add_action( 'wp_head', create_function('','echo "<script type=\'text/javascript\' src=\'https://apis.google.com/js/plusone.js\'></script>";'));
	if ( is_home() || is_archive()  ) {
		add_action('genesis_post_content', 'child_display_post_social_action_buttons');
	}
	if ( is_single() ) {
		add_action('genesis_post_content', 'child_display_post_social_action_buttons', 1);
	}
}

function child_display_post_social_action_buttons () {
	
		echo sprintf( '
		<div class="ED-social-media-action-buttons">
		<!-- Facebook Button -->
		<iframe src="http://www.facebook.com/plugins/like.php?href=%1$s&amp;layout=button_count&amp;show_faces=false&amp;width=90&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:90px; height:20px;"></iframe>
		<!-- Twitter Button -->
<script src="http://platform.twitter.com/widgets.js"; type="text/javascript"></script>
   <a href="http://twitter.com/share"; class="twitter-share-button"
      data-url="%1$s"
      data-via="JAlLBREAKS"
      data-text="%2$s"
      data-count="horizontal">Tweet</a>
<!-- Google Plus Button  -->
<g:plusone size="medium" href="%1$s"></g:plusone>
<!-- Pinterest Button  -->
<a href="http://pinterest.com/pin/create/button/?url=%1$s&amp;media=%3$s" class="pin-it-button" count-layout="horizontal"><img border="0" src="http://assets.pinterest.com/images/PinExt.png" title="Pin It" /></a>
</div> <!-- END ED-social-media-action-buttons -->
', get_permalink(), get_the_title(), wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ) );
}
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:52 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.