In this article, we’d like to share with you a small JavaScript library that we developed for one of the projects that we’ve been working on recently.

In our latest project we needed a simple and lightweight solution for the page notifications. Within the project we have notifications of several types – success or error notifications, warnings or purely informative ones.

We wanted to have two possible behaviors: some notifications should self close, ie. disappear spontaneously. On the other hand we need to have notifications that require user’s action – we want to be sure that the user actually noticed them before closing.

Within the project we do not use any external JavaScript library, so we wanted to have it in vanilla JavaScript.

You can see the code I ended up with the solution as you can see in this demo on Codepen. The notification may either be on the page when it loads or can be added at any other moment.

As for the IE support, it works in IE10+.

See the Pen Simple Notifications Solution – source code and demo by Paulina Hetman (@pehaa) on CodePen.

The demo uses the Bulma CSS framework, but it’s not necessary, you can style your notifications by scratch or use something else then BULMA.

In the pen above you’ll find the source code that I wrote for the library. If you want to use this small library directly in your project – you can check our github repo for more details. I also published the code to the npm registry and the production-ready minified script is available as, and the minified css file –

<!-- optional BULMA css -->
<link rel="stylesheet" href="">
<!-- Simple Notifications Solution css -->
<link rel="stylesheet" href="">
  /* override styles here */
  <p class="notification" data-close="self">Self-closing notification</p>
  <p class="notification">
    This one needs user's action.
    <button class="delete" type="button">Close</button>
  <!-- Bottom of body -->
  <script src=""></script> 
    var notifications = new Notifications();

You can check how it works in one of these pens, or, again, check the github repo for more details.


Default Settings

See the Pen Simple Notifications Solution – default by Paulina Hetman (@pehaa) on CodePen.

Custom ‘out’ animations

See the Pen Simple Notifications Solution, custom out animations by Paulina Hetman (@pehaa) on CodePen.

Custom ‘in’ animation

See the Pen Simple Notifications Solution, custom in animation by Paulina Hetman (@pehaa) on CodePen.

Hope some of you find it useful. Please share and enjoy! :)

I'm a front-end developer, WordPress developer and trainer. Otherwise coding, cooking and doing yoga. Polish, married to a french guy Joe Vains with whom we live in the very center of Paris.
Follow @PeHaa on twitter and on CodePen.


Leave a reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.