JS

parallax effect

const parallax = document.querySelector('.parallax');
const layers = parallax.children;

function moveLayersDepedingOnScroll(wScroll) {
  Array.from(layers).forEach(layer => {
    const divider = layer.dataset.speed;
    const strafe = wScroll * divider / 10;
    layer.style.transform = `translateY(-${strafe}%)`;
  });
}

window.addEventListener('scroll', e => {
  const wScroll = window.pageYOffset;
  moveLayersDepedingOnScroll(wScroll);
});

This example assumes that you have a div with a class of parallax that contains multiple children elements with different data-speed attributes, which will determine how much each layer will move based on the scrolling.