I have 135 html elements which I want to be faded in and out randomly, so I wrote this code for it:
setInterval(function() {
    ggg = Math.floor(Math.random() * (50 - 1 + 1) + 1);
    $("#f" + ggg).fadeIn(500, function() {  });
    $("#f" + ggg).fadeOut(500);
}, 300);
setInterval(function() {
    ggg = Math.floor(Math.random() * (100 - 50 + 1) + 50);
    $("#f" + ggg).fadeIn(500, function() {  });
    $("#f" + ggg).fadeOut(500); 
}, 300);
setInterval(function() {
    ggg = Math.floor(Math.random() * (135 - 100 + 1) + 100);
    $("#f" + ggg).fadeIn(500, function() {   });
    $("#f" + ggg).fadeOut(500);
}, 300);
But the problem is that it takes 50 percent of my i7 on Macbook Pro, even though there is no problem on a Windows laptop. Can someone rewrite the code for better performance?
 
     
     
     
     
     
     
    