Quickly Call User Name

I’m using a short script to call and display the users name, but it works very slowly, sometimes taking 10+ seconds to actually show the correct details.

Can I do anything to speed this process up?

import wixUsers from 'wix-users';
import wixData from 'wix-data';

$w.onReady(function () {
 const user = wixUsers.currentUser;
 const userId = user.id;
 const loggedIn = user.loggedIn;

 if (loggedIn) {
        wixData.query("Members/PrivateMembersData")
            .eq("_id", userId)
            .find()
            .then((results) => {
                $w("#userName").text = results.items[0].firstName;
            })
    }
}); 
  1. It shouldn’t take so long.

  2. If you use wixData.get() instead of query.find() it should be a little bit faster, but I don’t think it’s really noticeable.

  3. Try to see if using a data set element makes it faster…

Thank you, I’ll give that a go.