R
R
Rokis2017-08-30 19:52:08
Social media
Rokis, 2017-08-30 19:52:08

How to fix a bug that slows down the site with social buttons?

Hello.
I use these social buttons and recently noticed a bug that significantly slows down the loading of the site.

Failed to load resource: the server responded with a https://share.yandex.ru/gpp.xml?url=http%3A%2F%2Fsocial-likes.js.org%2Fru%2F&callback=jQuery220020035631438018187_1504109446300&_=1504109446301 
status of 500 (Internal Server Error)

The error on their home page is similar to the error on my site. How can it be corrected?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rokis, 2017-08-31
@Rokis

The problem was in the google+ counter.
I solved it with this code:

var url = "http://www.yoursite-to-be-counted.com";
var data = {
    "method":"pos.plusones.get",
    "id": url,
    "params":{
        "nolog":true,
        "id": url,
        "source":"widget",
        "userId":"@viewer",
        "groupId":"@self"
    },
    "jsonrpc":"2.0",
    "key":"p",
    "apiVersion":"v1"
  };
  $.ajax({
    type: "POST",
    url: "https://clients6.google.com/rpc",
    processData: true,
    contentType: 'application/json',
    data: JSON.stringify(data),
    success: function(r){
      setCount($(".google-plus-count"), r.result.metadata.globalCounts.count);
    }
  });

  var setCount = function($item, count) {
    if (count) {
      $item.text(count);
    }
  };

A
Alexander Pavlyut, 2017-08-30
@apavlyut

Load everything asynchronously if possible, but it depends heavily on the context, so you can see more details, for example, here https://css-tricks.com/thinking-async/
And figure out where and what to stick in your case.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question