How to Enable Lazy Loading for WordPress Comments
“Lazy Loading” is a technique that helps the important parts of your site load quickly for visitors.
Lazy Loading makes sure that page elements that are non-critical will load after the more important elements.
Imagine you open an article you want to read on the internet. Usually, you would start at the title and perhaps eventually read down to the comments. It makes perfect sense to load the title first and then load the comments later.
This technique can also apply to videos and images. Theses can be large elements, and often it's not necessary to display them immediately. Lazy Loading can ensure that you pull the video and image data only just before the element appears on the screen.
By default, WordPress loads the comments automatically. Lazy loading comments, particularly on posts with a big amount of comments (200-300), can improve your site performance. WordPress can load the title and body of the post and then load the comments later.
The Lazy Load for Comments plugin for WordPress prevents WordPress from displaying comments automatically and loads them on request.
Keep reading to learn how to use this plugin.
Step #1. Install the plugin
- Click Plugins > Add new.
- Type comments lazy load in the search box.
- Choose the Lazy Load for Comments plugin.
- Click Install now.
- Click Activate.
Step #2. The Plugin Configuration
- Click Settings > Discussion.
- Scroll down until you find the Lazy Load Comments dropdown.
- By default, On scroll is selected. Change this to On Click:
- Scroll down and click Save changes.
Step #3. Create a Post and Add Comments
Let’s create a post to test the lazy loading functionality.
- Click Posts > Add new.
- Enter a proper title and text.
- Click Publish twice.
- Open the post in another browser or in an incognito tab.
- Write a comment.
- Click Post comment.
Go back to the dashboard of your site in order to approve the comment.
- Click Comments.
- Look for the comment.
- Click Approve.
- Go back to the Post.
- Refresh the page.
You should see a “Load comments button” at the end of the post. If you click it, the comments will be displayed.
Lazy Load for Comments summary
With this plugin, you can definitely improve the page loading speed for articles with many comments. Your comments will also look cleaner and organized, which improves the user experience.
For more on comments, check our our guide to moderating comments, and our tutorial on controlling what comments authors can see.
More useful WordPress plugin recommendations
- Create a table of contents for WordPress posts
- How to link words in a WordPress post to a glossary
- Allow guests to submit content to your WordPress site
- Keep a log of all your site activity
Get the PublishPress plugins
Join PublishPress today and you'll get powerful publishing and permissions plugins to improve your WordPress site.