Update contributors.js for better performance

append element to the DOM too many times may cause performance issue,
so do it only once.
master
Rex Tsou 5 years ago
parent 7f5dc497da
commit 58afb74d46

@ -3,12 +3,14 @@ function getContributors() {
const container = $('#contributors');
jQuery.ajax('https://api.github.com/repos/mikebryant/ac-nh-turnip-prices/contributors', {})
.done(function (data) {
const contributorList = [];
data.forEach((contributor, idx) => {
container.append(`<a href="${contributor.html_url}">${contributor.login}</a>`);
contributorList.push(`<a href="${contributor.html_url}">${contributor.login}</a>`);
if (idx < data.length - 1) {
container.append(', ');
contributorList.push(', ');
}
});
container.append(contributorList.join(''));
});
}
}

Loading…
Cancel
Save