Webmaster tips » JavaScript

4 Performance Tips for Elements Matching in jQuery

Average rating
  • 4 out of 5 Stars
Rate this article
  1. Always use ID to select an element if you can. This is the fastest way to select elements.
  2. Avoid matching elements by class name. Selecting with class name only will make jQuery search every element in the entire page. If you need to match elements by classname then use the element tag combined with the class name.
    Avoid this:
    Do this:
  3. Narrow it down. For example, if you know that the elements you want to select are in the top menu of the page then specify it when selecting.
  4. Avoid selecting the same element more than once. Store your selected element or use chaining.
    Avoid this:
    Do this:
    Or this:
    var myElement = jQuery("#MyElement");
    // some more code...
Online Press Release Service.

Rate This Article

How would you rate the quality of this content?
Currently rated: 4 out of 5 stars. 2 people have rated this article.
  • 4 out of 5 Stars
  • 1
  • 2
  • 3
  • 4
  • 5

Related Articles

Adsense CCPA Settings

What is the CCPA and How It Affects AdSense Publishers?

CCPA stands for California Consumers Protection Act 2018. It is the law that requires businesses to give California residents special rights to restrict their personal information usage. In this article we will try to understand how it affects AdSense publishers and what publishers should do to comply with it. ..
CSS Vendor Properties

CSS Vendor Properties: The Complete Reference

According to the CSS specification, CSS identifiers may begin with '-' (dash) or '_' (underscore). These identifiers (keywords and property names) are reserved for vendor-specific extensions. ..
New HTML Elements

New Elements in HTML 5

Web pages and their design are laid out using HTML. HTML stands for Hyper Text Mark-up Language. HTML is comprised of 'tags' or elements that tell your browser what the different areas of your webpage are. ..

Why You Need an International PPC Campaign, and How to Do It

Are you using the power of PPC to get the international traffic you deserve? This sort of advertising can put a brand or service in front of global customers who would otherwise be out of reach.Even if you already benefit from PPC (pay-per-click) advertising, using the English language will only take you so far in the rapidly changing online landscape. ..

Partial Page Rendering Using Hidden IFrame

Partial-page rendering removes the need for the whole web page to be refreshed as the result of a postback. Instead, only individual regions of the page that have changed are updated. As a result, users do not see the whole page reload with every postback, which makes user interaction with the Web page more seamless. ..
Free Domain & 50% off Shared Hosting