Opening images in the background [closed]

-1

I want to know if it is possible to upload a webpage, the images do not interfere with loading the page, ie when you open the page execute and only then read the images, for the page to open 1 second and not 3 , for example.

How can I do such a thing?

    
asked by anonymous 01.09.2017 / 13:41

2 answers

3

You can use the LazyLoad plugin to upload images only when they are in the visible area of your browser screen.

The advantage of this is that there is a performance gain on page load and also saves users' internet bandwidth consumption, even more when they access your site via 3G or 4G. p>

Using Lazy Load is simple. Just add the script to <head> of your page:

<script language="javascript" src="jquery.lazyload.js"></script>

Then add the class .lazy to the images that will be affected:

<img class="lazy" data-original="imagem_real.png" src="imagem_pre.png" />

And call the function in the script:

<script>
$(function(){$("img.lazy").lazyload();});
</script>

Notes:

  • data-original is the path of the final image, which will be loaded when the area it is in is within the visible area of the browser.
  • In% with% you put the path of a generic image, which will be pre-loaded before the final image (create a lighter image possible as a 1x1 pixel png, for example).
  

Download the plugin and see the documentation on the link    link

    
01.09.2017 / 19:01
0

You can use some lazy loading technique in javascript to do this asynchronously.

There are some plugins for this, such as: link

Read more: link

    
01.09.2017 / 16:18