Unload files loaded with getScript?

后端 未结 5 1681
醉酒成梦
醉酒成梦 2020-12-10 06:57

With $.getScript I can load js files on the fly. Is it possible to \"unload\" some of these files ?

I have a ajax-based administrative panel. I have 3 sections. When

5条回答
  •  醉话见心
    2020-12-10 07:22

    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).

提交回复
热议问题