I use Youtube subscribe button (https://developers.google.com/youtube/youtube_subscribe_button ).
Is there any way, while user clicks on it, to initiate my javascript function too?
You just need to add a data element with the function that you need to run.
<script>
function myEvent(e)
{
// do something here
}
</script>
<div class="g-ytsubscribe" data-channel="GoogleDevelopers" data-onytevent="myEvent"></div>
https://developers.google.com/youtube/youtube_subscribe_button#Handling_Events_Demo