The answer from here works for me for preloading images:
https://stackoverflow.com/a/14390213/533426
body::after{
position:absolute; width:0; height:0; overflow:hidden; z-index:-1;
content:url(img01.png) url(img02.png) url(img03.png) url(img04.png);
}
I think instead of this position, width
etc you can use display: none
as well.
how can I create a mixin that takes an array of img urls and produces something like this:
content:url(img01.png) url(img02.png) url(img03.png) url(img04.png);
I was thinking of something like
@mixin preloadImgs($imgUrls){
&:after{
content: @each $imgUrl in imgUrls url('#{$imgUrl}');
display: none;
}
}
.
.test{
@include preloadImgs(['img01.png', 'img02.png', 'img03png']);
}