Simple question. If you include jQuery in a page of HTML, is there any initialization overhead before one uses any jQuery functions.
By virtue of simply including the jQuery script, you do indeed get some overhead. jQuery builds itself up inside an immediately executed function.
In 1.3.2 the biggest things it does are for IE support:
form
element with one input
element inside it, to check to see if the browser returns elements by name when querying by getElementById
- [Source]div
with a empty comment
node in it, to check to see if the browser returns only elements when doing getElementsByTagName("*")
- [Source]getAttribute
returns normalized href
attributes - [Source]creates a temporary div
with this html in it:
' <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select><object><param/></object>'
and proceeds to read off a bunch of characteristics from that structure. This is to build the jQuery.support
object that was created in lieu of deprecating jQuery.browser
- [Source]
It also does some smaller things like:
navigator.userAgent
for some deprecated browser sniffing support+new Date
)Keep in mind all this barely adds up to any noticeable lag, as others have suggested.
Yes, a tiny bit. On my very fast machine, it seems to delay the page load by about 4ms.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With