Debouncing and Throttling
function debounce(func, delay) {
  let timer;
  return function(...args) {
    clearTimeout(timer);
    timer = setTimeout(() => func.apply(this, args), delay);
  };
}

const searchInput = document.getElementById('search');

searchInput.addEventListener('keyup', debounce(() => {
  // Fetch suggestions based on search term here
}, 200));
function throttle(func, delay) {
  let shouldWait = false;
  return function(...args) {
    if (!shouldWait) {
      func.apply(this, args);
      shouldWait = true;
      setTimeout(() => shouldWait = false, delay);
    }
  };
}

window.addEventListener('resize', throttle(() => {
  // Update layout here
}, 100));