We have already seen how to make jQuery react to the loading of a web page. The $(document).ready() event handler can be used to fire off a function's worth of code, but there's a bit more to be said about it.

What's the meaning of "a function's worth of code" in the above context?

  • 1
    Hmm. How much code can go in "a function"? It's even more meaningless than "How long is a piece of string?", given that most functions call other, lower-level, functions. How much code is "in" the main() function of a C/C++ program? I think this is not a constructive question about English. – FumbleFingers Feb 5 '12 at 16:23

In general, a phrase of the form "An X's worth of Y" refers to some quantity of Y that fills a container of size X.


  • A year's worth of savings (all the savings you would save in a year's time)
  • A bottle's worth of champagne (enough champagne to fill a bottle)
  • A function's worth of code (enough code that it should be separated into a function)
|improve this answer|||||
  • 1
    Don't spoil the ship for a ha'p'orth of tar. – MetaEd Feb 3 '12 at 19:37

The literal meaning of "a function's worth of code" is "enough code for a function", that is, not so small an amount of code that it should be inlined, nor so large an amount that it should be refactored into multiple functions.

However, in the given context the amount of code really is not the issue: the important point is that a callback event handler is a single function, and if multiple functions are to be called for a single event, either the single handler must call them in turn, or a queue of functions must be maintained by the system. The $(document).ready() method supports a queue mechanism, which presumably is what the paragraph you gave is building up to.

|improve this answer|||||

"a function's worth of code" refers to code inside a "function".

|improve this answer|||||
  • No, unfortunately, it's not. – Kris Dec 28 '13 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.