For Clients
For Geeks

jQuery setTimeout

In: JavaScript|jQuery

In order to make certain jQuery function run after some amount of time, you can use setTimeout – a JavaScript function. Here is a snippet that will remove loading mask from your page, one second after a website was loaded.

1
2
3
4
5
jQuery(document).ready(function () {
	setTimeout( function() {
		jQuery('#loading_mask').hide();
	}, 1000 );
});

Note: You can setup loading mask to cover your whole website, or just some part (image gallery for example). This way you can achieve nice effect so user won’t see loading images.

Written by

Dejan Jacimovic is passionate entrepreneur & software developer with Master's Degree in Computer Science. He likes to share his thoughts on e-commerce business, management and life on StuntCoders magazine and his own blog.

Sell More With Magento & Facebook