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:
parent
6c7e9d3255
commit
731263b81c
|
@ -4,7 +4,7 @@ let S3BaseUrl, S3CDN;
|
||||||
export default function getURL(url) {
|
export default function getURL(url) {
|
||||||
if (!url) return url;
|
if (!url) return url;
|
||||||
|
|
||||||
if (!baseUri) {
|
if (baseUri === undefined) {
|
||||||
baseUri = $('meta[name="discourse-base-uri"]').attr("content") || "";
|
baseUri = $('meta[name="discourse-base-uri"]').attr("content") || "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue