the112,
<div id="show"></div>
<script>
let timer = (foo, num = 5,duration = 3000) =>
(function delay() {
foo(num);
--num && setTimeout(delay, duration);
})()
const foo = n => show.textContent = n; //foo = n => $.getScript("https://cdn.jsdelivr.net/npm/masonry-layout@4.2.2/dist/masonry.pkgd.min.js");
timer(foo)
</script>