Skip to content

Instantly share code, notes, and snippets.

@aswinsekar
Created October 13, 2018 06:01
Show Gist options
  • Save aswinsekar/ff7324cd4b16909cc9130652ae79ff20 to your computer and use it in GitHub Desktop.
Save aswinsekar/ff7324cd4b16909cc9130652ae79ff20 to your computer and use it in GitHub Desktop.
// IIFE - to print the trace where alert raised from
// Doesn't impact the alert behavior or any other behavior of your front end
// Add this code in your javascript or run it in console of your browser
// After adding, console will have stack trace of the alert printed
(function(proxied) {
window.alert = function() {
console.trace();
return proxied.apply(this, arguments);
};
})(window.alert);
// have used proxy approach for not disturbing the alert call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment