How to use Lazy Load in Wordpress

in utopian-io •  7 years ago  (edited)


lazyloadimages.png

What Will I Learn?

  • You'll learn how to improve your site perfomance with the well-known lazy load technique.

Requirements

  • Having installed the CMS Wordpress platform
  • Plugin BJ Lazy Load installed and activate
  • Plugin Regenerate Thumbnails installed and activate

Difficulty

  • Basic

Tutorial Contents

The loading time of web pages is fundamental to ensure a good experience for the user, so it is important to reduce it to the maximum. One way to improve this is to use the Lazy Load technique, which consists of loading content only when it is actually requested by the user. In this tutorial I explain how to use in the wordpress CMS platform.

Let's start by setting up the plugin to apply lazy load to our content on our site.

  1. Go to the menu "Settings"
  2. Click in "BJ Lazy Load"
  3. Apply to content: it'll be applied to the content of the site. This is a < div id = "content" class = "site-content"> ... </ div>
  4. Apply to text widgets:apply the lazy load technique to all widgets containing texts (in my case: yes)
  5. Apply to post thumbnails: (in my case: yes)
  6. Apply to gravatars: (in my case: yes)
  7. Lazy load images:apply the lazy load technique to all images in your web site (in my case: yes)
  8. Lazy load iframes:(in my case: yes)

1.JPG

Change the placehold.
3.JPG

In all the images that do not want to be applied the technique of lazy load I will put the class "no-lazy"
4.JPG

For example:

< img src="/pexels-photo-733533.jpeg"  width="1123" height="750" class="no-lazy" / >

Proximity of the viewport element must be loaded. In pixels.

5.JPG

Use low-res preview image: To use this functionality you need to install and activate the Regenerate Thumbnails plugin. (in my case:yes)
6.JPG

So let's now compress our images to be able to have low resolution images before we appreciate them with good quality.

  1. Go to the menu "Tools"
  2. Click in submenu "Regenerate Thumbnails"
  3. Regenerate Thumbnails forl all attachments

88.JPG

If we want to change the measurements of the thumbnails we can go to settings and make the change.

  1. Go to the menu "Settings"
  2. Click in submenu "Media"
  3. Change thumbnails measurements
    Save Changes.

77.JPG

Now that it is set up we can test the images on a test page.
10.JPG

If you don't want the page to use the lazy load technique, you can disable the plugin's use on the page itself.
11.JPG

With these steps all completed already is applied in its pages the technique of lazy load.

After rendering a page they can see in the code the images with these attributes:

  • data-lazt-type
  • data-lazt-src
  • data-lazy-srcset
  • data-lazy-sizes

< img src="http://localhost/wp/wp-content/uploads/2018/01/pexels-photo-696680.jpeg" data-lazy-type="image" data-lazy-src="http://localhost/wp/wp-content/uploads/2018/01/pexels-photo-696680.jpeg" alt="" width="1125" height="750" class="lazy alignnone size-full wp-image-97 lazy-loaded" data-lazy-srcset="http://localhost/wp/wp-content/uploads/2018/01/pexels-photo-696680.jpeg 1125w, http://localhost/wp/wp-content/uploads/2018/01/pexels-photo-696680-30x20.jpeg 30w, http://localhost/wp/wp-content/uploads/2018/01/pexels-photo-696680-300x200.jpeg 300w, http://localhost/wp/wp-content/uploads/2018/01/pexels-photo-696680-768x512.jpeg 768w, http://localhost/wp/wp-content/uploads/2018/01/pexels-photo-696680-1024x683.jpeg 1024w" data-lazy-sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" srcset="http://localhost/wp/wp-content/uploads/2018/01/pexels-photo-696680.jpeg 1125w, http://localhost/wp/wp-content/uploads/2018/01/pexels-photo-696680-30x20.jpeg 30w, http://localhost/wp/wp-content/uploads/2018/01/pexels-photo-696680-300x200.jpeg 300w, http://localhost/wp/wp-content/uploads/2018/01/pexels-photo-696680-768x512.jpeg 768w, http://localhost/wp/wp-content/uploads/2018/01/pexels-photo-696680-1024x683.jpeg 1024w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" >

Source image: 1

Curriculum

In my curriculum find tutorials on wordpress as it is my daily work tool. Many more will be made.



Posted on Utopian.io - Rewarding Open Source Contributors

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Thank you.

Hey @portugalcoin I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Suggestions

  • Contribute more often to get higher and higher rewards. I wish to see you often!
  • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!

Get Noticed!

  • Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x