AlertifyJS
AlertifyJS copied to clipboard
alertify global enable disable option
i do not know if there is global enable disable alertify flag option currently available or not . so it will be good to have global flag where we could enable disable alertify globally. like in development we use alerts but in product we do not want to show alerts of success errors etc.
Easiest method to solve it in your production code, is to prevent the script from loading by adding it dynamically if some conditions are met:
<script>
if (development) {
let alertify = document.createElement('script'), attr = {
type: 'text/javascript',
src: 'path/to/alertify.js',
crossorigin: 'anonymous'
};
for (let n in attr) {
if (attr.hasOwnProperty(n)) {
alertify.setAttribute(n, attr[n]);
}
}
document.head.appendChild(alertify);
}
</script>
Your request doesn't require any modification of alertify or how to implement it.
Another solution would be on every usage where it is not needed in production make use of a simple check:
if (development) { alertify.alert(title, text); }
// or a wrapper
function printError() {
if (development) {
alertify.alert.apply(alertify, arguments);
}
}
printError(title, text);
Greetings :)