I think that there are valid reasons to load and unload scripts. I have written a monitoring tool where content is swapped in and out of the center
all the time. Each load requires new functions to be attached to the just loaded content. If you (un)load js specific to the (un)loaded content, then the memory footprint stays small. And you can re-use previously defined function names for slightly different responses, while writing generic xhtml.
Assume a
with info on a peace of data. The user wants to edit that specific record so the
content is replaced by a form with all kinds of behaviors on buttons, checkboxes, etc. The form is subitted and the
is replaced with the original content but reflecting the changes. The form is gone and so is the need for any associated behavior.
I.m.h.o. loading in a certain
on your page x.htm + x.css + x.js and replacing them when other content and behavior is needed is by far preferrable over re-analyzing the new content and attach all possible responses even if certain nodes or classes are missing in the new content.
Instead of large javascript files, a set of pluggable js modules keeps my code well-organized and the maintenance of ajax behaviors relatively easy. Support for such a scheme in jQuery would be a tremendous help (for me).