JavaScript and its Use-Case in Spotify

Krishna Pal
3 min readJun 23, 2021

--

Introduction of Spotify:-

Spotify is a Swedish audio streaming and media services provider founded in 2006 by Daniel Ek. It is one of the world’s largest music streaming service providers, with over 356 million monthly active users, including 158 million paying subscribers, as of March 2021. Spotify offers digital copyright restricted recorded music and podcasts, including more than 90 million songs, from record labels and media companies. As a freemium service, basic features are free with advertisements and limited control, while additional features, such as offline listening and commercial-free listening, are offered via paid subscriptions. Users can search for music based on artist, album, or genre, and can create, edit, and share playlists.

What is JavaScript?

JavaScript is a cross-platform, object-oriented scripting language used to make webpages interactive (e.g., having complex animations, clickable buttons, popup menus, etc.). There are also more advanced server side versions of JavaScript such as Node.js, which allow you to add more functionality to a website than downloading files (such as realtime collaboration between multiple computers). Inside a host environment (for example, a web browser), JavaScript can be connected to the objects of its environment to provide programmatic control over them.

JavaScript contains a standard library of objects, such as Array, Date, and Math, and a core set of language elements such as operators, control structures, and statements. Core JavaScript can be extended for a variety of purposes by supplementing it with additional objects; for example:

  • Client-side JavaScript extends the core language by supplying objects to control a browser and its Document Object Model (DOM). For example, client-side extensions allow an application to place elements on an HTML form and respond to user events such as mouse clicks, form input, and page navigation.
  • Server-side JavaScript extends the core language by supplying objects relevant to running JavaScript on a server. For example, server-side extensions allow an application to communicate with a database, provide continuity of information from one invocation to another of the application, or perform file manipulations on a server.

This means that in the browser, JavaScript can change the way the webpage (DOM) looks. And, likewise, Node.js JavaScript on the server can respond to custom requests from code written in the browser.

How Spotify uses JavaScript?

JavaScript is used across the Spotify desktop client. Wherever UI is concerned, it uses JavaScript. C++ is used for functionality beneath the UI, with JavaScript sitting on top of it. The languages are connected by an interface aptly called a ‘bridge.’ Spotify Interface using Chromium Embedded Framework. The interface layer called Cosmos is a perfect bridge between C++ and JavaScript and hence, interacting with different views in no more a trouble for the developers. On top of that, there is a layer of PHP that mainly executes the logging in and some apps on different domains. The rest of the part is JavaScript as far as the overall interface is concerned. JavaScript uses a specialized C++ service to ace to the backend.

JavaScript helps in fetching songs based on type of Artist, Recent listening, Artist Collection, Your own built playlist, New Releases, Today’s Recommendation and much more. As whatever song you want to listen, your queries renders JavaScript category selection function, event listener function and many more function to display results according to that. JavaScript also has use case in authorization access flow in Spotify.

JavaScript work architecture in Spotify

Node-js an open-source, cross-platform, back-end JavaScript runtime environment that runs on the V8 engine and executes JavaScript code outside a web browser. Node-js also play an vital role in developing Spotify API.

Here is the link for Web API Libraries of Spotify:-

Thanks for Reading…😊

--

--

Krishna Pal
Krishna Pal

Written by Krishna Pal

Engineering Student || Aspiring DevOps Engineer || Tech Enthusiast

No responses yet