WordPress asynchronously loads social media sharing buttons

It’s important to share things through social networks. Not only that, the page load time! This quick tutorial shows how to load the social media sharing buttons in word press themes asynchronously and improve page speed. What does \
See: Step 1 of loading JavaScript only on a specific word press page: create a JavaScript file, such as a shared name. Specify as JS and place it in the JS folder in the theme root folder. The codes are as follows:
\/*Script for asynchronous load of sharing buttons*\/
(function (W, D, s){
Function go(){
Var JS, fjs = d.getelementsbytagname (s) [0], load = function (URL, ID){
If (d.getelementbyid (ID)) {return;}
JS = d.createelement (s); Js SRC = URL; Js Id = ID;
Fjs Parentnode InsertBefore (JS, fjs);
};
\/\/Facebook
Load (‘\/\/connect.facebook.net\/en\u us\/all.js\xfbml=1′,’fbjssdk’);
\/\/Google+
Load (‘ https:\/\/apis.google.com\/js\/plusone.js ‘,’gplus1js’);
\/\/Twitter
Load (‘\/\/platform.twitter.com\/widgets.js’,’tweetjs’);
\/\/Linedin
Load (‘\/\/platform.linkedin.com\/in.js’,’lnkdjs’);
\/\/Pinterest
Load (‘\/\/assets.pinterest.com\/js\/pinit.js’,’pinitjs’);
}The
If (w.addeventlistener) {w.addeventlistener (\
Else if (w.attachevent) {w.attachevent (\
}(window, document,’script’); Male \/ * script for asynchronous load of sharing buttons * \/ (function (W, D, s) {function go() {var JS, fjs = D. getelementbytagname (s) [0], load = function (URL, ID) {if (D. getelementbyid (ID)) {return;} JS = D CreateElement (s); JS SRC = URL; JS

Author:

Leave a Reply

Your email address will not be published. Required fields are marked *