Subscribe For Free

Thursday, January 25, 2018

Preload Images On Your Website With JavaScript

This code will prevent your site form taking more time to load. This kind of situation looks bad but is also unprofessional. All you have to do is add your images to the preloadImages section and you are ready to roll.

<script type="text/javascript">

    var images = new Array();

    function preloadImages(){

        for (i=0; i < preloadImages.arguments.length; i++){

            images[i] = new Image();

            images[i].src = preloadImages.arguments[i];



    preloadImages("logo.jpg", "main_bg.jpg", 
        "body_bg.jpg", "header_bg.jpg");


No comments:

Post a Comment

click it