Implementing a live leaderboard

Another nice feature of amp-live-list is that updates can be applied automatically, without the need to click or tap a button. This is very useful for live-updating of scores that you might find in sport, such as football scores, or leaderboard style rankings that you would find in racing and election results.

Let's implement a live Grand Prix position leaderboard. To get the list items to update without having to press the update button, we need to make sure that we do the following:

  • Don't change any item IDs after initial load: If you introduce new IDs, then the update button will be displayed.
  • Include the data-update-time attribute: If the latest server update contains a value higher than the current value ...

Get AMP: Building Accelerated Mobile Pages now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.