简体   繁体   中英

How to stop Twitter Timeline Widget from Polling?

I'm using the Twitter embedded Timeline Widget on the login page for a single-page Backbone application. When the user logins in, I change the page via Backbone routing and the Twitter widget is no longer displayed. However, if you look at the Network panel of the browser developer tools, there are requests to http://syndication.twimg.com/widgets/timelines/paged/ ... every 15 seconds or so. How can I stop these requests?

If I delete window.twittr , I get 6 "Uncaught ReferenceError: twttr is not defined" errors from timeout callbacks...which works, but doesn't seem very clean. Is there a better way?

I believe setting a Tweet limit could be an option.

Tweet limit: To fix the size of a timeline to a preset number of Tweets, use the data-tweet-limit="5" attribute with any value between 1 and 20 Tweets. The timeline will render the specified number of Tweets from the timeline, expanding the height of the widget to display all Tweets without scrolling. with any value between 1 and 20 Tweets. The timeline will render the specified number of Tweets from the timeline, expanding the height of the widget to display all Tweets without scrolling. Since the widget is of a fixed size, it will not poll for updates when using this option.

https://dev.twitter.com/docs/embedded-timelines

eg

<a class="twitter-timeline" href="https://twitter.com/twitterapi" data-widget-id="YOUR-WIDGET-ID-HERE" data-chrome="nofooter" data-tweet-limit="3">Tweets by @twitterapi</a>

And then if desired you could update your widgets manually, by removing them reinserting the html then calling.

twttr.widgets.load()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM