We are fatigued to fighting with various WordPress Plugin’s conflict ultimately lowering our Google PageSpeed score. Despite setting the CORS rightly – actually you can not physically cache the external images, javascripts. It is quite dangerous to use the web server or even a dedicated loadbalancer as both forward and reverse proxy. CORS is the only way to add new header, but javascripts usually escapes. I understood, we probably have some dogma with these junks. Together, Facebook + Twitter + Google Plus + Pinterest add approximately 500 KB extra materials. What we need is sharing. Once we wrote about a cheating method to create a Facebook fan box widget that loads faster on your blog.
So, we historically HAD ONLY 121 LIKES AND IT HAS GROWN without any Fan Box. Basic logic is – none will give like, follow or share unless impressed. Because there is no Social Network exits which never require login. Sharing, logically should give better SEO Signal
than Like
or Plus
. So, only Sharing. Sharing is Caring. Who will share can invest a bit time. Earning ONE faithful follower / sharer is better than TWENTY peoples with swinging mood. With Plus, Like etc. actually we capture more digits, but how much the “Digits” are sticky, that has no warranty.
PageSpeed Friendly Social Sharing For WordPress : Most Social Sharing Plugins Are Junks
After stripping out the Google Feedburner form for the sake of HTTPS and implementing Click To Subscribe
button, I noticed that, eventually it is ‘Call to Action’ that matters. The Facebook fan box cheating can be done on the sidebar – to make fat free – Base64 Encoding.
---
The plugin developers can not be fully blamed, to make the plugins compatible with 99% themes (70% of them are badly coded), they need to add lot of stuffs. Brian (Gardner) developed a good social sharing plugin with sharrre library (Genesis Simple Share), but it sucks at one point – you can not asynchronously load all the javascripts – HTML5 DOM element issue related to sharrre.
You can use the CSS, Icon Font of Genesis Simple Share for decoration purpose. If you are dyeing to get the digits, its actually ver easy, most social network related counts can be fetched using simple cURL as JSON output. If you want the digits, you have to work more (we do not recommend to work so much, it will suck some resource of your server), the counts are cached by social network’s server, you can call them by on hover
event.
Socialite is another library which enables this HTML5 on hover event in better way :
1 | https://github.com/tmort/Socialite |
We are showing you the full code of basic PageSpeed Friendly Social Sharing Buttons For WordPress which we are using. 100% CSS and HTML. We could use the existing Icon Font already loaded on the page. But it will increase the round trip delay time. The browser engine will invisibly re-check whether the material already downloaded is right or not. This is the normal hierarchy of a HTML5 WordPress page (roughly) :
– Header –
– HTML Header –
– WordPress Header –
– HTML Body-
– WordPress Post Body –
– WordPress After Post Body –
– WordPress Sidebar Materials –
– WordPress Footer –
– HTML Body Ends-
If you suddenly call a jQuery pseudo DOM element (CSS pseudo-elements) in the WordPress After Post Body
which is deferred, DOM will never get rendered. Additionally, you might be inviting more trouble out of PHP’s bugs. Obviously this is desired :
1 | https://developers.google.com/speed/pagespeed/insights/?url=https%3A%2F%2Fthecustomizewindows.com%2F2013%2F01%2Fhsdpa-3g-usb-modem-brands-and-models-non-vendor-locked%2F |
Score on PageSpeed Insights is usually 91/100, unless we flush all type of caches – PHP5-FPM, Nginx, LuaJIT rules, XCache, W3 Total Cache, InnoDB Cache. The servers are computers, it takes a bit time to rebuild the cache. 96/100 on WebPageTest :
1 | http://www.webpagetest.org/result/140927_P6_9QE/ |
Raw processing power of Rackspace with Akamai’s support. Next level is having own data centers across the globe! Thats what Facebook has :
1 | http://www.webpagetest.org/result/140927_3P_A66/ |
98/100. Its 98, because they have no external ads. In other words, if you are using any B Grade Cloud Computing platform, you can not score like us.
PageSpeed Friendly Social Sharing For WordPress : Full Codes
This is our code to create the hyperlinks :
And here is the CSS (scroll down fast to skip this part, tl;dr) :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | .social { align-content: stretch; align-items: stretch; align-self: stretch; box-sizing: border-box; color: #333333; display: block; flex: 0 1 auto; flex-basis: auto; flex-direction: row; flex-flow: row; flex-grow: 0; flex-shrink: 1; flex-wrap: nowrap; font: normal normal 400 18px/30px Helvetica; height: 70px; justify-content: flex-start; margin: 30px 0px; order: 0; resize: none; text-align: center; width: 100%; } .social a { color: #FFF; border: none; } .social .twitter { -o-transition: 0.5s cubic-bezier(0, 0, 0.58, 1); -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; -webkit-border-radius: 5px; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -webkit-transition: 0.5s cubic-bezier(0, 0, 0.58, 1); -webkit-transition-delay: 0; -webkit-transition-duration: 0.5s; -webkit-transition-timing-function: cubic-bezier(0, 0, 0.58, 1); align-content: stretch; align-items: stretch; align-self: stretch; background: #00ACED; border-radius: 5px; box-sizing: border-box; color: #FFFFFF; cursor: pointer; display: inline-block; flex: 0 1 auto; flex-basis: auto; flex-direction: row; flex-flow: row; flex-grow: 0; flex-shrink: 1; flex-wrap: nowrap; height: 50px; justify-content: flex-start; margin: 10px 0px; order: 0; padding: 10px 30px; position: relative; resize: none; text-align: center; text-decoration: none; transition: 0.5s cubic-bezier(0, 0, 0.58, 1); width: 109px; } .social .twitter:hover { background: #0074a1; } .social .google { -o-transition: 0.5s cubic-bezier(0, 0, 0.58, 1); -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; -webkit-border-radius: 5px; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -webkit-transition: 0.5s cubic-bezier(0, 0, 0.58, 1); -webkit-transition-delay: 0; -webkit-transition-duration: 0.5s; -webkit-transition-timing-function: cubic-bezier(0, 0, 0.58, 1); align-content: stretch; align-items: stretch; align-self: stretch; background: #DD4B39; border-radius: 5px; box-sizing: border-box; color: #FFFFFF; cursor: pointer; display: inline-block; flex: 0 1 auto; flex-basis: auto; flex-direction: row; flex-flow: row; flex-grow: 0; flex-shrink: 1; flex-wrap: nowrap; height: 50px; justify-content: flex-start; margin: 10px 0px; order: 0; padding: 10px 30px; position: relative; resize: none; text-align: center; text-decoration: none; transition: 0.5s cubic-bezier(0, 0, 0.58, 1); width: 81px; } .social .google:hover { background: #ac2d1e; } .social .pinterest { -o-transition: 0.5s cubic-bezier(0, 0, 0.58, 1); -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; -webkit-border-radius: 5px; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -webkit-transition: 0.5s cubic-bezier(0, 0, 0.58, 1); -webkit-transition-delay: 0; -webkit-transition-duration: 0.5s; -webkit-transition-timing-function: cubic-bezier(0, 0, 0.58, 1); align-content: stretch; align-items: stretch; align-self: stretch; background: #cb2027; border-radius: 5px; box-sizing: border-box; color: #FFFFFF; cursor: pointer; display: inline-block; flex: 0 1 auto; flex-basis: auto; flex-direction: row; flex-flow: row; flex-grow: 0; flex-shrink: 1; flex-wrap: nowrap; height: 50px; justify-content: flex-start; margin: 10px 0px; order: 0; padding: 10px 30px; position: relative; resize: none; text-align: center; text-decoration: none; transition: 0.5s cubic-bezier(0, 0, 0.58, 1); width: 81px; } .social .pinterest:hover { background: #a82400; } .social .facebook { -o-transition: 0.5s cubic-bezier(0, 0, 0.58, 1); -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; -webkit-border-radius: 5px; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -webkit-transition: 0.5s cubic-bezier(0, 0, 0.58, 1); -webkit-transition-delay: 0; -webkit-transition-duration: 0.5s; -webkit-transition-timing-function: cubic-bezier(0, 0, 0.58, 1); align-content: stretch; align-items: stretch; align-self: stretch; background: #3B5998; border-radius: 5px; box-sizing: border-box; color: #FFFFFF; cursor: pointer; display: inline-block; flex: 0 1 auto; flex-basis: auto; flex-direction: row; flex-flow: row; flex-grow: 0; flex-shrink: 1; flex-wrap: nowrap; height: 50px; justify-content: flex-start; margin: 10px 0px; order: 0; padding: 10px 30px; position: relative; resize: none; text-align: center; text-decoration: none; transition: 0.5s cubic-bezier(0, 0, 0.58, 1); width: 93px; } .social .facebook:hover { background: #263961; } |
Change the &via=AbhishekCTRL
to &via=YOUR-TWITTER-HANDLER
. Both, Facebook and Twitter can convert non- url encoded URLs, you need not to give Encoded URLs. Their servers will convert them.
Regarding count, count can easily be fetched, for example with Facebook :
1 | https://api.facebook.com/method/fql.query?query=select total_count,like_count,comment_count,share_count,click_count from link_stat where url='https://thecustomizewindows.com/2014/09/mysql-innodb-optimization-cnf/'&format=json |
If you want to make it PHP, you need cURL and PHP lib curl :
Obviously, you can turn the buttons looking better by using icon font like we shown in Twitter inline text sharing. This is a living demo of inline sharable link without any Javascript – You can retweet our Install WordPress with Nginx on Rackspace Cloud Server guide! Do it!. This is what has been used :
1 | <a href="https://twitter.com/intent/tweet?original_referer=https%3A%2F%2Fthecustomizewindows.com%2F2014%2F08%2Finstall-wordpress-nginx-rackspace-cloud-server%2F&text=Install%20WordPress%20with%20Nginx%20on%20Rackspace%20Cloud%20Server&tw_p=tweetbutton&url=http%3A%2F%2Fbit.ly%2F1sLQugH&via=AbhishekCTRL" class="retweet" rel="nofolow" target="top"><i class="icon-twitter">You can retweet our Install WordPress with Nginx on Rackspace Cloud Server guide! Do it!</i></a> |
You can possibly create an icon font library with Twitter Bird and Click to RT
written as icon. On that class the hyperlink class should not have any decoration, to keep the things need.
Fragment cache the block for optimal page speed. Although, W3TC will gzip it with already converted hyperlink. Oho, you’ll get all the hex value of social media colors here :
1 | http://designpieces.com/2012/12/social-media-colours-hex-and-rgb/ |
By the way, my code fills the description field in Pinterest and never seeks pin other than post’s material.