There’s a foreign JS file which is not loaded from our server on my page. In short I dont have any control on that file and I can’t edit the file. I have created 1 function which I wish to call after the function which is in that foreign file is called.
I know the name of function of foreign file. I wish to call my function once the function from foreign file is executed. How can I do it?
Let me know if you dont understand my problem here. I’ll try and explain it again.
Thanks in advance
If the foreign function is in the global scope you can replace it with your own wrapper:
Note the use of
.applyto ensure that whatever context and arguments were supplied to the original function are still supplied to it. Without that, thethisvariable inside that function may not be what it’s supposed to be.