EpicUsaMan2016-12-08 13:03:28
EpicUsaMan, 2016-12-08 13:03:28

AJAX and unloading scripts?

There is a main.js file that includes js files for certain pages by URL parsing and in case the URL is not found in the list, socket.io starts. In included js files, jquery events.
And there is also menu.js, which is connected on each page and it has loading parts of the page using AJAX.

Now the question is, if the script src="parsed.url.js" tag is removed, will the events created in it be unloaded, as well as the connection to socket.io? If not, how to do it so as not to jam each event manually.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Eugene, 2016-12-08

Events will not be unsubscribed, because the page continues to exist - there was no reload, you just deleted the file. So you can think over the architecture again, or figure out how to unsubscribe from all events. You can set an array of all events and when you disable something, go through this array and unsubscribe.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question