Tutorial: Building the Simplest JS Notification Library

Tutorial: Building the Simplest JS Notification Library

Few days ago I was asked to create a solution to work with JS Notification for a web app in the same way apps like WhatsApp web does. So, I went to the docs, read it and got quite surprised how easy it is to use the native API. For a little while I thought my work was already done and, even better, without any dependences from frameworks, only pure Javascript.


Before I talk about the issues on my Notifications project, let’s see how use it.

That’s simplest example of notification:

Try it yourself

Pretty cool, eh?

In the example above we are only printing the attribute title of the notification. There are other attributes we can declare to have a better experience with our notification and, yay, those are almost working in the same way at the main browsers (except for IE family, of course. But we are talking about real browsers, aren’t we? But don’t worry, we’ll create a way to give a fallback to them).