Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alertify global enable disable option #188

Open
darkworks opened this issue Jun 19, 2018 · 1 comment
Open

alertify global enable disable option #188

darkworks opened this issue Jun 19, 2018 · 1 comment
Labels

Comments

@darkworks
Copy link

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.

@anotherCoward
Copy link

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants