Labels

php (35) javascript (31) phpjavascript (30) jquery (23) html (20) mysql (14) database (9) codeigniter (4) json (4) bar chart (2) calendar (2) column chart (2) framework (2) google maps (2) query (2) tables (2) url (2) dropdown (1)

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");

</script>

2 comments:

  1. Welcome to the Best writer Review, Here you can get the best All Assignment Help reviews sites. We strongly urge you to check our entire website once and we will assure you will find this review website very useful. Our hard work will be rewarded if students like you will appreciate our effort and spread the message about this site with your class-fellows and friends.

    ReplyDelete

More Posts

FOLLOW