There is a generated IIFE function inside script tag from CRM, and I need to call this function on button click, is there any way to do this?
<script data-b24-form="click/18/3h30a2" data-skip-moving="true">
(function(w,d,u){
var s=d.createElement('script');s.async=true;s.src=u+'?'+(Date.now()/180000|0);
var h=d.getElementsByTagName('script')[0];h.parentNode.insertBefore(s,h);
})(window,document,'https://');
</script>
No, you can't, if that code is automatically generated and you can't do anything to change it.
The function is never saved anywhere, it's just run once and then discarded. Since it's never saved anywhere, there's nothing you can use to call it.
If you could change the code, then of course you could save the function and use it in your click handler:
<script data-b24-form="click/18/3h30a2" data-skip-moving="true">
// Create the function without calling it, store it in `theFunction`
var theFunction = function(w,d,u){
var s=d.createElement('script');s.async=true;s.src=u+'?'+(Date.now()/180000|0);
var h=d.getElementsByTagName('script')[0];h.parentNode.insertBefore(s,h);
}.bind(window, window,document,'https://');
theFunction(); // The initial call
// In your click handler, call `theFunction`.
</script>