Blog

WordPress

Posted on — Last updated on October 11, 2019

WordPress Popular Posts 4.1 is here!

This release includes WordPress REST API integration, At-a-Glance statistics, and bumps minimum supported WP version to 4.7

WordPress Popular Posts just received a major update that includes a few new & shiny features I hope you all will enjoy!

The last few releases were mostly focused on improving the plugin: bug fixes, small performance tweaks, documentation updates. Now it’s time for new things!

At a Glance

Personally, my favorite feature from this release.

At a Glance is that small widget from the Dashboard where you can take a quick look at the general statistics of your site:

  • Total number of posts.
  • Total number of comments.
  • Total number of pages.

Useful, yet it feels like it really hasn’t gotten enough love from WordPress developers in general.

Akismet is the only plugin -that I know of- that takes advantage of this highly visible spot of the admin dashboard to display a summary of its anti-spam statistics. Until today.

WordPress Popular Posts: At a Glance widget views statistics
At a Glance: see how many pageviews your site has received in the last hour

Now, besides seeing how many posts, comments and pages you have on your site, you’ll also find a new item in the list where you can quickly gauge how many pageviews your site has received within the last hour. Click on it and you’ll land in WPP’s Stats section. Neat!

Integration with the WordPress REST API

Back in December 2016, with the release of WordPress version 4.7 “Vaughan” the REST API was officially introduced to the ecosystem – a major step towards WordPress’ goal of becoming a full-fledged application framework. Soon enough, developers from all over the world started building powerful web apps with WordPress at its core.

Unlike the Ajax API, the REST API offers us developers a way to build structured RESTful interfaces to handle asynchronous requests, and with less overhead than the traditional admin-ajax.php (Delicious Brain ran a performance comparison between the two and found the latter to be up to 16% faster).

The performance gain alone was enough reason to experiment with the REST API.

John Watkins (@johnwatkins0), a fellow developer from Maine, USA was kind enough to send a PR with all the groundwork laid out for integrating the plugin with the REST API. Thanks again, John!

Faster pageviews tracking, faster page loading times!

One of the first changes that came with the integration with the REST API was the way WordPress Popular Posts used to track your posts and pages.

WordPress Popular Posts relied on the Ajax API to keep track of your site’s pageviews. While this worked pretty well, it still took WPP some time to update the views count of a given page due to the fact that the Ajax API is slow: admin-ajax.php loads a bunch of non-essential core WordPress files just to process a single asynchronous request.

Credit: Delicious Brains, Inc.

While this has no significant impact on small / low-traffic sites, you can tell how your site’s performance degradates as it grows in both traffic and content over time.

The REST API also loads a chunk of WordPress core when processing a request but the overhead is significantly less when compared to admin-ajax.php which results in faster response times from the server.

Credit: Delicious Brains, Inc.

While the difference might not seem a lot right now, it really does adds up in the long run.

New endpoints to fetch popular posts

Performance aside, this release also includes WordPress Popular Posts’ own REST API Endpoints.

WordPress Popular Posts' REST API endpoint
The WordPress Popular Posts’ REST API endpoint in action!

To most users this probably isn’t a big deal, but developers building WordPress-based complex (web) applications will surely appreciate this: now you can also list your most popular posts on your (web) app!

For a list of available endpoints, please visit the REST API Endpoints wiki page.

Oh, in case you haven’t realized it yet, all of the above implies that WordPress Popular Posts will now require WordPress 4.7 or newer to run.

New Time Range in the Stats section

Before this release, I often found myself wanting to see Today’s most popular posts. To do that, I had to click on Custom, then on Date Range, then pick today’s date and finally click on Apply. That was a whole lot of clicking just to see what was popular today.

New Time Range: Today!

From WPP 4.1 and on, all I have to do now is click on “Today” and be done with it. Nice!

No more jQuery on the front-end!

I love jQuery. It’s really handy. I have used it extensively in many projects throughout the years.

However, loading an entire JS framework and use only a couple of its features seem like a waste of resources: you’re having the browser load a heavy (as in Kb) library for no good reason.

As of WPP 4.1, the plugin will stop including jQuery in your posts & pages. Instead, it’ll load a lean, minified custom built library that’ll load a lot faster and that contains everything the plugin needs to do its thing.

That’s not all, folks!

WordPress Popular Posts 4.1 is not just new features. It also includes a few fixes as well, so upgrade as soon as possible.

If you’re curious, you can find the complete changelog here.

Enjoy!