I want to reduce page loading time. Social icons (Facebook Like, Twitter follow etc) takes up a lot of speed.
I want to display a static image of the like buttons, and on mouse hover, display the actual buttons.
I can do this easily by loading the real buttons in a hidden div that I show()
on hover, but this means that the content will be loaded regardless.
Is there any way to only load the buttons on hover?
EDIT:
For example, when user hovers over image, it loads up Facebook like button:
Top of <body>
:
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.3";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
Display button:
<div class="fb-like" data-href="https://developers.facebook.com/docs/plugins/" data-layout="button" data-action="like" data-show-faces="true" data-share="true"></div>