Alternatives to Twitter @Anywhere API?

1.6k views Asked by At

I'm attempting to put a tweet box on my website by simply using the @anywhere API by Twitter. While this works fine and is simple to set up, it has the following problems with it:

Are there any other alternatives to using @anywhere?

Edit: Here's my code..

<div id="twitter_widget">
        <script src="http://platform.twitter.com/anywhere.js?id=**MYAPPID**&v=1"></script>
        <script type="text/javascript">
        twttr.anywhere(function (T) {
            T("#twitter_widget").tweetBox({
            label: "<span style='display:block !important;margin-bottom:5px !important;font-family:Helvetica Neue !important; color: #CCC !important; font-size: 18px !important; font-weight: 500 !important;'>Tweet</span>",
            height: 100,
            width: 300,
            defaultContent: ""
            });
        });
        </script>
        <button class="check-twitter" onclick="window.open('http://www.twitter.com','_blank');">Go to Twitter</button>
    </div>
3

There are 3 answers

1
Sripathi Krishnan On BEST ANSWER

I am not aware of alternatives to @anywhere. But I don't believe the 3s / 14 requests affect you.

From Twitter's documentation -

"All dependencies for @Anywhere features are loaded asynchronously, on-demand so as to not impact performance of the host page"

In short, this means your page is almost decoupled from Twitter's library. The user should be able to use your page even if Twitter's widgets take a long time to load. It doesn't solve the "loading 14 requests" problem, but it ensures Twitter's performance problems don't become yours.

Notice that I said almost above. Loading an external script as part of you can slow down your entire site. If Twitter's servers are facing a problem, it can lead to a Front End Single Point of Failure.

UPDATE : Per Twitter, loading anywhere.js asynchronously isn't supported. The solution I mention below may or may not work for you, proceed with caution.

So, the best solution I can come up with is loading anywhere.js itself asynchronously. If you are using jQuery, the code would like this -


//Assumes jQuery was loaded

jQuery.getScript("http://platform.twitter.com/anywhere.js?id=&v=1", function(data, textStatus) {
twttr.anywhere(function (T) {
            T("#twitter_widget").tweetBox({
            label: "Tweet",
            height: 100,
            width: 300,
            defaultContent: ""
            });
        });
});


Put this code just before your closing </head>. It will load anywhere.js asynchronously, and call twitter's function only after the js has loaded.

5
Till On

If you want to use @anywhere, you can't do much about it. I've noticed random things in the beginning (like downtime and what not). But generally platform.twitter.com should be speedy enough since it's served by Akamai.

How did you determine it's three seconds, and what exactly takes three seconds? The entire page, or just loading the external JS, etc.?

Your only other option is to use another option which does not rely on including third-party code. That's the only fast option. Third part websites can always be slow, unless of course there is an SLA which guarantees availability and performance.

1
rds On

The alternative is to make your site a twitter client. That requires you to support oAuth & the twitter API.