Skip to content

Instantly share code, notes, and snippets.

// example HTML:
// <img class="background-image" src="images/mobile/everydaycare.jpg">
// Description: Serve mobile image first, and swap directory if page is desktop
function swapImageMobileFirst() {
var $bgImages = $('img.background-image');
var loadCount = 0;
$bgImages.each(function(){
// Get image src