Loading/unloading Javascript dynamically

后端 未结 1 1613
野性不改
野性不改 2021-01-28 22:37

We are creating a dynamic web application where only some parts of the web page will get loaded/unloaded/reloaded through JQuery AJAX.

But we are concerned what will hap

相关标签:
1条回答
  • 2021-01-28 23:27

    If you bind all of the functions to some object you can free the object with all the functions any time you want. For example:

    function badFunction(a,b,c) {
       alert("Bad example of function. Can't cleanup this.";
    }
    
    var gameObject = new Object();
    gameObject.goodFunction = function (a,b,c) {
       alert("Good example of a function");
    }
    
    //Here the whole gameObject 'module' will be allowed to be garbage collected (hopefully).
    gameObject = null;
    
    0 讨论(0)
提交回复
热议问题