PERF: Correctly memoize baseUri value in javascript app (#9986)

An empty string is a falsey value in javascript, so we were looking for the meta tag every time getURL was called, which took approximately 1.5ms every time.
This commit is contained in:
David Taylor 2020-06-05 13:36:48 +01:00 committed by GitHub
parent 6c7e9d3255
commit 731263b81c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -4,7 +4,7 @@ let S3BaseUrl, S3CDN;
export default function getURL(url) {
if (!url) return url;
if (!baseUri) {
if (baseUri === undefined) {
baseUri = $('meta[name="discourse-base-uri"]').attr("content") || "";
}