// resizing function call processHeightAdjust('product-col'); //declare the array var processHeightJsNodes = []; function processHeightAdjust() { //checks that processHeightJsNodes array exists, if not create it var processHeightJsNodes = processHeightJsNodes || []; //looks to see if the values have been chached if not, assigns them if(!processHeightJsNodes[0]){ for (i = 0; i < arguments.length; i++) { //takes the arguments, finds the nodes and pushes them to the procressHeightJSNodes array processHeightJsNodes.push(document.getElementsByClassName(arguments[i])); } } //for each ccs class for (i = 0; i < processHeightJsNodes.length; i++) { var max = 0; var elements = []; //assign the notes to the elents array elements = processHeightJsNodes[i]; //look through them, if the height is more than the max height make it the max height for (x = 0; x < elements.length; x++) { //this line lowers the efficiency but is necessary if you want //the heights to adapt to making the window bigger, not just shrinking elements[x].setAttribute("style","height:"+"auto"); if(elements[x].clientHeight > max) max=elements[x].clientHeight; } for (y = 0; y < elements.length; y++) { //loop through the elements and apply that max height to them all elements[y].setAttribute("style","height:"+max+"px"); } } } (function() { var throttle = function(type, name, obj) { obj = obj || window; var running = false; var func = function() { if (running) { return; } running = true; requestAnimationFrame(function() { obj.dispatchEvent(new CustomEvent(name)); running = false; }); }; obj.addEventListener(type, func); }; /* init - you can init any event */ throttle("resize", "optimizedResize"); })();