Following the example of facebook
You can do this by using a function in javascript
:
function changeTitle() {
var titulo = document.title;
var numero = 5; // Número de notificações a ser exibidas
var novoTitulo = '(' + numero + ') ' + titulo;
document.title = novoTitulo;
}
It depends on you to change the numero
variable to get the amount of notifications your user has.
In the case of facebook and many other sites that use this technique, the result is obtained through reactive frameworks, example React , Vue , etc ...
in the title
tag has the following
<title>{{notificações}} Facebook</title>
If WebSocket detects a new notification, the "notifications" interpolation will update with the correct value, this concept is called Two way data binding