RoarJS – JavaScript Alert/Confirm Replacement

👋 Ciprian on Wednesday, May 9, 2018 in Blog, JavaScript
Last modified on Monday, August 17, 2020

Learn JavaScript by example. Code snippets, how-to's and tutorials. Try now!

RoarJS is a wonderful, responsive, customisable, accessible (WAI-ARIA), zero-dependency, vanilla JavaScript alert/confirm replacement.

RoarJS automatically centers itself on the page and looks great no matter if you’re using a desktop computer, mobile or tablet.

RoarJS is free, tiny and it works in any browser.

How to use

Demo 1: A basic alert

roar('A basic title');

Demo 2: A basic alert with title, message and Confirm button:

roar('A basic title', 'This is a basic message. As basic as it can get. What now?');

Demo 3: An alert with title, message, Confirm button and Cancel button

var options = {
	cancel: true,
	cancelText: 'cancel',
	cancelCallBack: function (event) {
	confirm: true,
	confirmText: 'confirm',
	confirmCallBack: function (event) {

roar('Official enquiry', 'Do you like <strong>Roar</strong> so far? Do you?', options);

What?! Do you need more?

That’s it! Less than 200 lines, 775 bytes (gzipped) or 3.87 KB minified.

How to install

<link rel="stylesheet" href="roar.min.css">
<script src="roar.min.js"></script>

Or include it in your JavaScript functions file and your main stylesheet.

How to reuse

If you need to reuse the script in several modules, such as in your WordPress theme and in your WordPress plugin, use the below:

var myRedeclaredRoar = function roar(title, message, options) {
    // Roar function here

No kittens were harmed in the making of this script.

Find more JavaScript tutorials, code snippets and samples here or more jQuery tutorials, code snippets and samples here.

Buy me a coffee to support my work!

👋 Added by Ciprian on Wednesday, May 9, 2018 in Blog, JavaScript. Last modified on Monday, August 17, 2020.

Leave a Reply

You have to agree to the comment policy.

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

Privacy Policy