From 731263b81ce027f9fe85dce07a8c576549a7d153 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Fri, 5 Jun 2020 13:36:48 +0100 Subject: [PATCH] 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. --- app/assets/javascripts/discourse-common/addon/lib/get-url.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse-common/addon/lib/get-url.js b/app/assets/javascripts/discourse-common/addon/lib/get-url.js index eb36586e8d5..a74ea5ff64f 100644 --- a/app/assets/javascripts/discourse-common/addon/lib/get-url.js +++ b/app/assets/javascripts/discourse-common/addon/lib/get-url.js @@ -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") || ""; }