Given the code example you show, you are trying to check if jQuery has been extended using that function:
if ($.fn.sb_save)
The way you're trying to call the function
sb_save();
shows this is not what you intended.
Instead, to simply check if sb_save
is an executable object (a.k.a. function
), use the most upvoted answer from the question you linked:
if (typeof sb_save === 'function')
function sb_save() {
alert('saving');
}
$('button').on('click', function() {
if (typeof sb_save === 'function') {
sb_save();
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button>CLICK</button>