Force Javascript to Load First

Discussion in 'JavaScript' started by forumposters, Jun 5, 2007.

  1. #1
    I have an image gallery with many fairly large images on some pages. And, these pages take about 10 seconds to all load. While the images are downloading, my javascript menu does not appear. Is there a way to tell the browser to load the javascript before any of the images on the page?
     
    forumposters, Jun 5, 2007 IP
  2. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Got code? :)
     
    MMJ, Jun 6, 2007 IP
  3. NoamBarz

    NoamBarz Active Member

    Messages:
    242
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Maybe if you place the loading section in a function and only call that function when the page is loaded.


    The loading function:

    function PreLoad(){
    var images = new Array();
    images[0] = new Image();
    images[0].src='www.somewhare.com/Images/img1.jpg';
    images[1] = new Image();
    images[1].src='www.somewhare.com/Images/img2.jpg';
    }


    call the function when the page is loaded:

    <body onload="javascript:preLoad();">
     
    NoamBarz, Jun 7, 2007 IP