Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7775175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:33:47+00:00 2026-06-01T17:33:47+00:00

Well, the title pretty much describes my question: How to load the background-image dynamically

  • 0

Well, the title pretty much describes my question:

How to load the background-image dynamically after it has been fully loaded? Sometimes, I must use backgrounds that are so big that it can take a while for the browser to download it. I’d rather ‘load it in the background’ and let it fade in when it has been fully loaded.

I think jQuery would be best to be using, but I also want my background to appear if JavaScript has been disabled. If this really isn’t possible, so be it, but I think it is?

Best regards,
Aart

……..

EDIT:

Thanks a bunch, guys! I’ve been bugged with this for ages and just couldn’t think of a nice and easy way.

I converted Jeffrey’s Javascript-solution into a jQuery one, just because jQuery’s built-in fade looks so awesome.

I’ll just post it here in case anyone else has the same issue:

<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>
<script type='text/javascript'>
    $(document).ready(function() {
        $('#img').css('opacity','0').load(function() {
            $(this).animate({
                opacity: 1
            }, 500);
        });
    });

</script>

<img src='yourimage.jpg' id='img'/> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:33:48+00:00Added an answer on June 1, 2026 at 5:33 pm

    If the image is included with an img element:

    <img src="bg.jpg" id="img" onload="this.style.opacity='1'">
    
    <script>
        document.getElementById("img").style.opacity="0";
    </script>
    

    That should load the image normally if JavaScript is disabled, but show it only once it loads assuming it’s enabled.

    One thing to note (that I overlooked): some browsers will not even attempt to load an image if its display property is none. That’s why this method uses the opacity attribute.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well the title pretty much sums the question. The only thing I found is
Well, the title is pretty much the whole question. I'd like to be able
Well the title Question pretty much sums it up, But I'd like to detail
Well, the title's pretty much it: if I sat a non-techie/my mum/twelve-year old boy/cocker
Well the title pretty much says it all. I had: $strata = new Zend_Form_Element_Select('strata');
Well, the title pretty much sums it up, really. I've only just started toying
The title sums my question up pretty well: are there any open source OpenGL
well, the title pretty much says it all. here's a little info: i have
Well the title pretty well describes my problem. Here is a little bit more
Think the title describes my thoughts pretty well :) I've seen a lot of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.