Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Can I make javascript load before images?

  • 22-04-2008 6:20pm
    #1
    Closed Accounts Posts: 238 ✭✭


    Hey,

    I've a photo gallery on a site that's using Lytebox (modification of Lightbox 2). It's working great except when the thumbnail image is clicked before all the thumbnails load...then it loads just the image without the Lytebox effect. This could be problematic for users with slow connections...

    Does the javascript need to be preloaded somehow? Can I set that to be ready before thumbnails are shown?

    Here's the gallery - follow through to an image.

    The script works by having the reference to the .js in the <head>...
    <script type="text/javascript" language="javascript" src="lytebox.js"></script>
    <link rel="stylesheet" href="lytebox.css" type="text/css" media="screen" />
    I've the styles added into my own stylesheet, don't think that matters though.

    Then adding the rel="lyteshow[album]" in the link from the thumbnail to the image file loads an album slideshow in lytebox...
    <a href="images/image-1.jpg" rel="lyteshow[album]" title="Image Description">Image #1</a>


Comments

  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    You could try adding the Javascript source at the bottom of the page, thus making it the last element called for loading, but depending on the relative sizes of the script and image that may not make much difference.


  • Closed Accounts Posts: 238 ✭✭chat2joe


    ...thus making it the last element called for loading.....
    But would I not want it to be the first thing to be loaded?


  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    Dammit. I got the problem arseways :) Definately need sleep.


  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    The DOM will need to be fully available before the JavaScript is triggered. One way to speed this up is

    1) Specify widths and heights for all elements
    2) Maybe (as a last resort) load a single transparent gif as the source for all image elements and swap it when the page is loaded.


Advertisement