Skip to content

Instantly share code, notes, and snippets.

@franksmule
Last active January 1, 2016 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save franksmule/8187358 to your computer and use it in GitHub Desktop.
Save franksmule/8187358 to your computer and use it in GitHub Desktop.
Fade in high resolution image, where body is initially set to low resolution image.
jQuery(function ($) {
var newpic = new Image();
newpic.onload = function()
{
var $div = $('<div id="temp-background"/>').css({
'background-image': 'url(low-resolution-image.jpg)',
'position': 'absolute',
'height' :'100%',
'width' :'100%',
'z-index' :'-1',
'top' :'0px',
'left' :'0px',
});
$('body').append($div);
$("body").css('background-image', 'url(high-resolution-image.jpg)');
$('#temp-background').fadeOut(1000);
};
newpic.src = 'high-resolution-image.jpg';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment