Home Forums Basel support forum Avoid excessive specificity on jQuery selectors

Avoid excessive specificity on jQuery selectors

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #226966

    pierredemeudon
    Participant

    Hi there,

    I received this insight from a test:

    You are using too specifics jQuery selectors. It could impact performance. Here is an example of a good use of the library:

    $( “.data table.firstClass td.secondClass” );
    // Better: Drop the middle if possible
    $( “.data td.secondClass” );

    We found some too specifics selectors on your website:

    polinacouture.com/wp-content/themes/bas[…]tions.js?ver=5.3.0

    $(‘.basel-sticky-btn .basel-sticky-btn-wishlist a’)
    $(‘.basel-sticky-btn .basel-sticky-btn-wishlist a’)
    $(‘.basel-sticky-btn .basel-sticky-btn-compare a’)
    $(‘.basel-sticky-btn .basel-sticky-btn-compare a’)
    $(“.woocommerce .cart_totals table”)
    $(“.mobile-nav .site-mobile-menu .menu-item-has-children”)

    How to manage?

    Kind regards

    #226984

    Artem Temos
    Keymaster

    Hello,

    Such a selector is required in that case and we can’t simplify it. Note that even if we change it in these 5-7 places, it will not improve your website performance at all. You may see the difference if you have thousands of such selectors on your website.

    Kind Regards

Viewing 2 posts - 1 through 2 (of 2 total)