Maximum number of var / function definitions in Javascript?

I am currently working on an HTML5 / JS mobile project, and I have just added a set of β€œ40 requests” classes to the JS infrastructure for a clearer client-server communication. My boss questioned the use of so many classes because he thinks we might run into future problems with the number of variables and functions defined immediately. My argument is that we should write for intelligibility first and worry about optimization in the future when this becomes a problem.

So my question is, is this concern justifiable - is there a (rather low) limit on the number of variables and functions that can be defined right away, and does it depend on each browser or device basis?

Edit:

An example request file is as follows, where JSONRequest is the "extension" of AbstractRequest:

function MyServerRequest(content, info, otherData, callback, ignoreErrors) { var requestData = new RequestData("MyServerRequest"); requestData.messageType = MyConst.MY_END_POINT; requestData.message = { something: content, anotherthing: { blah: info } thirdthing: otherData }; JSONRequest.call(this, requestData, callback, ignoreErrors); } MyServerRequest.prototype = Object.create(JSONRequest.prototype); MyServerRequest.prototype.constructor = MyServerRequest; 
+6
source share
1 answer

There is no hard limit on the number of variables or functions that your JavaScript may contain, but you should be aware of the file sizes, and beware of the possibility of accidentally assigning two variables or functions to the same thing.

If you have some functions that are not needed on all pages, you should split them into several JavaScript files and include only those that you need.

+1
source

Source: https://habr.com/ru/post/943878/


All Articles