Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
206 views
in Plugins by 1 flag
edited by

Update Highlights

  • Smarter database requests - Instead of sending separate requests for each user one by one, they're now grouped into a single batch fetch. This reduces the overhead of repeated network/database round trips.
     
  • Lazy loading for badges - This one has been in the to-do list for a while now, as I've noticed websites with large amounts of badges suffering from this.

    Badges page:

    The list of users who earned badges now only loads when clicked, and as you scroll down the pop-up, more content is loaded dynamically, making the page faster and easier to navigate.

    After closing a pop-up, the list is destroyed to minimize nodes, while maintaining good performance.

    Once a list of badges is fully loaded, meaning the scroll has reached the end, it will save the list temporarily in memory, so it wont fetch the same list again, in case you reopen it for that page visit.
     
  • Better code organization - Organized files and created a “utils” file that holds common functions used throughout the site, making future updates simpler and more modular.
     
  • Fresh new look for the Badges pop-up - The pop-up box on the Badges page has been redesigned for a cleaner, more user-friendly experience.
     

Download: GitHub 
Live preview: Q2A Badges Live



1 Answer

+1 vote
by
selected by
 
Best answer

[5.2.37] - 2025-06-21

Widget Batch Fetching + User Account Data Caching

  1. Collect all user handles into an array while looping through badges.
  2. Batch fetch all user accounts at once via fetch_user_accounts()
  3. Cache user data in $userAccounts to avoid repeated database calls.

Badge Details Caching

  • Added $badgeCache to cache badge details by slug.
  • Avoid repeated option/database lookups for badges already processed.

Other

  • Refactor: Moved badge-utils.php to inc folder for better organization.
  • Reuse functions from badge-utils.php for the widget, instead of redeclaring them.
  • Updated default user avatar to a smaller .svg image.
...