getButterfly
Resume

RoarJS – JavaScript Alert/Confirm Replacement

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.

Get RoarJS from GitHub

How to use

Demo 1: A basic alert

Try me

roar('A basic title');

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

Try me

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

Try me

var options = {
	cancel: true,
	cancelText: 'cancel',
	cancelCallBack: function (event) {
		console.log('options.cancelCallBack');
	},
	confirm: true,
	confirmText: 'confirm',
	confirmCallBack: function (event) {
		console.log('options.confirmCallBack');
	}
}

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.


One comment on “RoarJS – JavaScript Alert/Confirm Replacement

Comments are closed.


My Battle Tested Recommendations

Jetpack
Dreamhost
WordPress.com
CodeCanyon
SEMrush

Disclaimer: These recommendations contain affiliate links.