Jump to content

Function Limits


buckibooster

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 comment
Share on other sites

See...

 

http://refresh-sf.com/yui/

 

http://www.w3schools.com/tags/att_script_src.asp

 

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 comment
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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...