Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you want to speed up page loading with the <code>background-image</code> loading asynchronously, you could use the following trick to do it with javascript (I have used this trick several times): </p> <p>Remove the image from you css and html, then create a javascript-function that pre-loads your image and optionally displays a loading overlay. Then you could do something like this (jQuery):</p> <pre><code>var backgroundImageUrl = "PathToYourBackgroundImage.png"; $(function() { PreLoadOverlayImage(backgroundImageUrl); }); // Preloads the image from the given url // and displays a loading overlay while doing so function PreLoadOverlayImage(url) { var html = "&lt;img class='preloadingImg' src='" + url + "' style='display:none' /&gt;"; $("body").append(html); // Self coded function, displays a modal loading screen over the full document // to disable interaction while it is loading, this is optional $("body").showLoading(); $(".preloadingImg").load(function () { $(".preloadingImg").remove(); // Remove the modal loading overlay $("body").hideLoading(); // Display background image $("body").css("background-image", backgroundImageUrl); }); } </code></pre> <p>It uses the caching functionality from the browser. The browser takes the url of the image you are loading to determine if it was loaded already in the past. If the url is already known to the browser it will load the cached image instead of re-downloading it from the server. Therefor when you assign it as the background of your body after loading it with an <code>&lt;img&gt;</code> it will be loaded immediately.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload