Soft Reject - JS. Proper Event Binding need help


#1
  1. http://envato.d.pr/aSlx

  2. PROPER EVENT BINDING: Consider using the preferred .on() method rather than .click(), .bind(), .hover(), .load(), .ready(), etc. For best performance and concise code use event delegation whenever possible: https://codepen.io/32bitkid/post/understanding-delegated-javascript-events

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


#2

Your link demo please add here, regards.


#3

$("#some-element").on(“click”, function() {

});

  1. Don’t:
    if ($(".some-class").hasClass(“test”)) {
    $(".some-class").addClass(“test2”);
    $(".some-class").show();
    $(".some-class").hide();
    }
    DO:
    var element = $(".some-class");

if (element.hasClass(“test”)) {
element.addClass(“test2”);
element.show();
element.hide();
}


#4

fixed

PROPER EVENT BINDING: Consider using the preferred .on() method rather than .click(), .bind(), .hover(), .load(), .ready(), etc. For best performance and concise code use event delegation whenever possible: https://codepen.io/32bitkid/post/understanding-delegated-javascript-events1


#5

here is my all js activation code.

(function($) {
‘use strict’;

jQuery(document).ready(function() {

    /*START PRELOADED*/
    $(window).on('load', function() {
        $('.preloader').fadeOut();
        $('.preloader-area').delay(350).fadeOut('slow');
    });
    /*END PRELOADED*/

    /*SRART  STICKY JS*/
    $(".header_top_area").sticky({
        topSpacing: 0,
    });
    /*END  STICKY JS*/

    /*START COUNTER UP JS*/
    $(".count_number").counterUp({
        time: 2000,
        delay: 10
    });
    /*END COUNTER UP JS*/

    /*START MIXITUP JS*/
    $('.work-posts').mixItUp();
    /*END MIXITUP JS*/

    /*START MAGNIFICENT POPUP JS*/
    $('.work-popup').magnificPopup({
        type: 'image',
        gallery: {
            enabled: true
        }
    });
    /*END MAGNIFICENT POPUP JS*/

    /*START PARALLAX JS */
    $(window).stellar({
        responsive: true,
        positionProperty: 'position',
        horizontalScrolling: false
    });
    /*END PARALLAX JS*/

    /*START TESTIMONIAL JS*/
    $(".testimonial_list").owlCarousel({
        items: 1,
        autoPlay: true,
        navigation: false,
        itemsDesktop: [1199, 1],
        itemsDesktopSmall: [980, 1],
        itemsTablet: [768, 1],
        itemsTabletSmall: false,
        itemsMobile: [479, 1],
        autoHeight: true,
        pagination: true,
        slideSpeed: 500,
        paginationSpeed: 500,
        transitionStyle: "backSlide"
    });
    /*END TESTIMONIAL JS*/

    /*START PERTNER JS*/
    $(".product_list").owlCarousel({
        items: 4,
        autoPlay: true,
        navigation: true,
        navigationText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"],
        itemsDesktop: [1199, 4],
        itemsDesktopSmall: [980, 2],
        itemsTablet: [768, 2],
        itemsTabletSmall: false,
        itemsMobile: [479, 1],
        autoHeight: true,
        pagination: false,
    });
    /*END PERTNER JS*/

    /*START SMOTH JS*/
    $('a.smoth-scroll').on("click", function(e) {
        var anchor = $(this);
        $('html, body').stop().animate({
            scrollTop: $(anchor.attr('href')).offset().top - 70
        }, 1000);
        e.preventDefault();
    });
    /*END SMOTH JS*/

    /*START MENU HIDE JS*/
    $(document).on('click', '.navbar-collapse.in', function(e) {
        if ($(e.target).is('a') && $(e.target).attr('class') != 'dropdown-toggle') {
            $(this).collapse('hide');
        }
    });
    /*END MENU HIDE JS*/

    /*START BOOTSTRAP SCROLL-SPY*/
    $('body').scrollspy({
        target: '.navbar-collapse',
        offset: 195
    });
    /*END BOOTSTRAP SCROLL-SPY*/

    /*START SCROLL TO UP*/
    $(window).scroll(function() {
        if ($(this).scrollTop() > 250) {
            $('.scrollup').fadeIn();
        } else {
            $('.scrollup').fadeOut();
        }
    });
    $('.scrollup').on("click", function() {
        $("html, body").animate({
            scrollTop: 0
        }, 800);
        return false;
    });
    /*END SCROLL TO UP*/

#6

need fix

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