What is the best way to change JavaScript implementations at runtime?
I have a web application that connects to a server using SignalR .
If there is any problem connecting to the server using SignalR at runtime, I want to change the implementation of the services functions to work with regular XHR.
I have one js file with the following functions to connect via SignalR :
function initializeConnection() {
}
function sendEcho() {
}
And another js file with the same functions for connecting via XHR :
function initializeConnection() {
}
function sendEcho() {
}
I know that they cannot be downloaded at the same time. I know that I can use one file with a switch inside each function.
, , , , . ? , ?
?