What is the playlist on Youtube?

What are the good ways to implement "Add to Playlist" like the YouTube?

  • Given - Lets say I have an API that returns all the playlists for a user - Now when user click "Add to Playlist", it is given with options with all the existing playlists that user has Question - When user clicks on "Add to Playlist", is it then when API gets called and gives the list of playlists?    if No    Where can I save that data?(cookies?) and When do I refresh/update it   If Yes   Are we not adding more communication between client and server every time a user is clicking "Add to Playlist" button? Worst case, User doen't add anything, then what? the data is still the same between client and server, but we make extra API call, which is expensive   I am very new to area of web application and not very sure how to deal with this scenario.  All I have a similar interface and I am about to give a Ajax call from jQuery.   Please advice as to how to work with such scenarios and where should the application specific related data should reside on client-side  Any references to books, tutorials, blogs, SO, Quora is highly appreciated Thank you

  • Answer:

    I doubt the expensiveness of that API. Returning all playlists for a user doesn't sound that expensive too me if user only has few playlists. If user has 20+ or 50+ playlists, it doesn't make sense to show all of them to user, picking one of the playlist from 20+ or 50+ is not a good experience. Maybe providing an auto-suggest input field is a good idea. Yes, you should get the playlists only when user clicks "Add to Playlist" button. This is what Youtube does today.

Hongqi Wang at Quora Visit the source

Was this solution helpful to you?

Other answers

In Youtube there is ajax call and there is a reason behind it. Not everybody in the world has a fast internet - so your page size matters. The number of people who hit the add to playlist option is < 1%. This makes it unnecessary to load this information while pageload. Just like add to playlist - there are many other things which do an ajax call. This means you are doing alteast 10 more queries for a single page load which is totally unnecessary. There is one optimization you can adopt. If you see typeahead in search, this is done via ajax - when you type "aja" you get a result , next if you make search string "ajax" you can just filter out things from the previous results. Similarly here you can just load the playlist once - load it into variable and for every next call to show playlist - use this data.

Anil Shanbhag

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.