Jump to content

Recommended Posts

I have an application that needs about a dozen separate unrelated and independent javascript functions to run as designed. At present, they are all in a single header (about 17,700 lines of code). All of them, except one, have less than 100 lines of code. The one exception has over 16,000 lines of code. Is there any limit to the number of javascript functions that can appear in a header? Is there a limit to the function size? Do they have to be placed in any specific order? If yes, I'm assuming that I will have to carve them out into separate included js files. If this is the case, the number and order of separate included js files will depend on the answer to these questions.

Link to post
Share on other sites







You will have to determine whether the browser can handle that much code without balking. The whole idea of using functions is to break a task down into manageable code segments.You will probably need to break that code up so that it can be executed in sections.

Link to post
Share on other sites

There aren't any hard limits on the amount of Javascript code that a browser will handle. I've never seen an issue caused by just having too much Javascript code. It's going to be more efficient to transfer a single file versus multiple files. As far as the order goes, that depends on how you define your functions. If you do it like this:var some_func = function() ...then you need to define those functions in the code before using them. If you just do this:function some_func() ...then the order doesn't matter, the code will be scanned first and all of the functions will be defined before it starts executing. The first method defines the function at run-time, so in that case the order matters.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...