Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
cantera25

Event Utility Library Still Needed When Using Jquery?

Recommended Posts

While your questions seem to be directed at Larry, I hope you don't mind if I add my two cents.

 

In general, you're right about vanilla JS being faster for event handling (mainly because there's less overhead), but for things like searching by class name (which is not natively supported in all versions of JS), jQuery will likely be faster unless you have the knowledge to very efficiently write a function that can select the best way to search for a class in the DOM depending on the browser.

 

As a side note, I didn't quite get your comment about returning an object vs. an element reference. Could you please explain this.

 

As for whether a utility library is necessary, well, I guess that's up to you. Any time you use a utility library (and jQuery is just a glorified utility library), you risk adding unnecessary bloat to your application for the sake of ease of use. It's really up to you to decide where to compromise.

 

Of course, there are exceptions where utility functions will both make the writing of your code easier as well as make your code more efficient. For example, if you're using the getElementById method a lot, then a utility function with a short name (like $), will greatly speed up the writing of your code as well as make your code more efficient because you can write $ instead of document.getElementById every time, thus making your code shorter (and load faster).

 

Anyway, just my thoughts.

Share this post


Link to post
Share on other sites

My general attitude it to write my own for relatively simple uses and simpler sites. Like just a couple of pages and nothing too involved. If I'm going to be using JavaScript regularly on a site and for more complex things, then I turn to jQuery.

Share this post


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.

Guest
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.

Loading...
Sign in to follow this  

×
×
  • Create New...