Need help with two Js issues in soft-rejected please.

I got a soft-rejected based on these two reasons:

  1. CACHE JQUERY OBJECTS: Please cache your jQuery selectors to improve performance: https://jsperf.com/why-cache-jquery-selectors
  1. $(function() {}) is a shorthand for $document.ready(), you are calling this function concurrently.

==============================================================================

This is my item: http://www.crenoveative.com/envato/togoby/

Very appreciated

1 Like

Your can add your all code js where
"//ADD YOUR CODE JS HERE"

jQuery(document).on(‘ready’, function ($) {
“use strict”;

//ADD YOUR CODE JS HERE

}(jQuery));


Regards. :slight_smile:

What about this one?

CACHE JQUERY OBJECTS: Please cache your jQuery selectors to improve performance: https://jsperf.com/why-cache-jquery-selectors

1 Like

What about this one?

CACHE JQUERY OBJECTS: Please cache your jQuery selectors to improve performance: https://jsperf.com/why-cache-jquery-selectors

Reviewer has give you clear messages. You should do

var $window = $(window),
      navbar = $("#navbar");

if ( $window.width() > 992 ) {
    // bla bla bla
} 

$window.scroll(function() { });

navbar.find('li').each( function() { ..... });

instead calling those objects multiple times

if ( $(window).width() > 992 ) {
     .......
}

$(window).scroll(function(){
  ......
});

good luck!

2 Likes

Thanks! But I need one more to be clear. What should I do more with this one?

navbar.find(‘li’).each( function() { … });