Skip to content

Instantly share code, notes, and snippets.

@ammarm08
Created November 1, 2018 13:47
Show Gist options
  • Select an option

  • Save ammarm08/360b06947c4b2a57e032b723c164bfd2 to your computer and use it in GitHub Desktop.

Select an option

Save ammarm08/360b06947c4b2a57e032b723c164bfd2 to your computer and use it in GitHub Desktop.
jQuery vs Vanilla Javascript
/*
Credits: https://www.codementor.io/brainyfarm/jquery-vs-vanilla-javascript-deciding-on-what-to-use-6b79xdmrv
*/
// jquery!
$(el).fadeIn();
// javascript!
function fadeIn(el) {
el.style.opacity = 0;
var last = +new Date();
var tick = function() {
el.style.opacity = +el.style.opacity + (new Date() - last) / 400;
last = +new Date();
if (+el.style.opacity < 1) {
(window.requestAnimationFrame && requestAnimationFrame(tick)) || setTimeout(tick, 16);
}
};
tick();
}
fadeIn(el);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment