Repeater slow load time and bugs

Hi.
I am new to code so sorry if I am missing something but I am pretty sure my code elements are all loading only it’s Ready $w(" #myDataset ").onReady( () => { ); } ); as you suggested here.
The rate hasn’t changed when I reduced the temp to display either. Appreciate your help.
Thanks.

import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;
$w.onReady( () => {
if (wixUsers.currentUser.loggedIn) {
$w(“#login”).label = “Logout”;
$w(“#profileButton”).show();
$w(“#image”).show();
}
else {
$w(“#login”).label = “Login”;
$w(“#profileButton”).show();
$w(“#image”).show();
}
} );

export function loginButton_click(event,$w) {
// user is logged in
if (wixUsers.currentUser.loggedIn) {
// log the user out
wixLocation.to(/);
wixUsers.logout()

  .then( () => { 

// update buttons accordingly
$w(“#login”).label = “Login”;
$w(“#profileButton”).show();
$w(“#image”).show();
} );
}
// user is logged out
else {
let userId;
let userEmail;

// prompt the user to log in
wixUsers.promptLogin( {“mode”: “login”} )
.then( (user) => {
userId = user.id;
return user.getEmail();
} )
.then( (email) => {
// check if there is an item for the user in the collection
userEmail = email;
return wixData.query(“Members”)
.eq(“_id”, userId)
.find();
} )
.then( (results) => {
// if an item for the user is not found
if (results.items.length === 0) {
// create an item
const toInsert = {
“_id”: userId,
“email”: userEmail
};
// add the item to the collection
wixData.insert(“Members”, toInsert)
. catch ( (err) => {
console.log(err);
} );
}

// update buttons accordingly
$w(“#login”).label = “Logout”;
$w(“#profileButton”).show();
$w(“#image”).show();
} )
. catch ( (err) => {
console.log(err);
} );
}
}
export function profileButton_click(event) {
wixLocation.to(/Member-Profile/${wixUsers.currentUser.id});
}

import wixWindow from ‘wix-window’;

$w.onReady( () => {
if (wixWindow.rendering.renderCycle === 1) {
if (wixUsers.currentUser.loggedIn) {
$w(“#login”).label = “Logout”;
$w(“#profileButton”).show();
$w(“#image”).show();
}
else {
$w(“#login”).label = “Login”;
$w(“#profileButton”).show();
$w(“#image”).hide();
}
}
} );