What js code should I choose?

We decided on a maximum to optimize the js code in terms of speed for google page speed.

Source code:

/* The index of the slide by default */
var slideIndex = 1;
showSlides(slideIndex);

/* Function increases the index by 1, shows the following slide*/
plusSlide function() {
 showSlides(slideIndex += 1);
}

/* Function umenshaet index 1, shows previous slide*/
minusSlide function() {
 showSlides(slideIndex -= 1); 
}

/* Sets the current slide */
function currentSlide(n) {
 showSlides(slideIndex = n);
}

/* The main function of the slider */
showSlides function(n) {
 var i;
 var slides = document.getElementsByClassName("item");
 var dots = document.getElementsByClassName("slider-dots_item");
 if (n > slides.length) {
 slideIndex = 1
}
 if (n < 1) {
 slideIndex = slides.length
}
 for (i = 0; i < slides.length; i++) {
 slides[i].style.display = "none";
}
 for (i = 0; i < dots.length; i++) {
 dots[i].className = dots[i].className.replace(" active", "");
}
 slides[slideIndex - 1].style.display = "block";
 dots[slideIndex - 1].className += "active";
}


Cut through online service:

var slideIndex=1;showSlides(slideIndex);plusSlide function(){showSlides(slideIndex+=1)}function minusSlide(){showSlides(slideIndex-=1)}function currentSlide(n){showSlides(slideIndex=n)}function showSlides(n){var i;var slides=document.getElementsByClassName("item");var dots=document.getElementsByClassName("slider-dots_item");if(n>slides.length){slideIndex=1}if(n<1){slideIndex=slides.length}for(i=0;i<slides.length;i++){slides[i].style.display="none"}for(i=0;i<dots.length;i++){dots[i].className=dots[i].className.replace(" active","")}slides[slideIndex-1].style.display="block";dots[slideIndex-1].className+=" active"}


Both are working fine. 2nd a little faster.

Tell me, is it worth to change the original cut or is it not necessary. And may still have some important point to optimize the download speed of this particular code.
March 19th 20 at 08:51
1 answer
March 19th 20 at 08:53
no not worth it.
for minifying code, there is special tools.
but the code is written primarily for people because in the source it is not necessary to leave
@evi , Thanks, I will consider. - anissa_Nikolaus8 commented on March 19th 20 at 08:56

Find more questions by tags JavaScript