From 0f3e87911f59ed399df3b6fe570e30371b1794b6 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 23 Jan 2020 12:05:43 +0100 Subject: [PATCH] Return early in `PDFViewerApplication._parseHashParameters` when the hash is empty For people running e.g. Firefox with the `pdfBugEnabled` preference set, to allow quick access to debugging tools, this method will obviously run for every opened PDF file. However, in most cases the URL hash is empty and we can thus skip most of the parsing and simply return early instead. --- web/app.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/web/app.js b/web/app.js index 58984c9e3..8c1e20a52 100644 --- a/web/app.js +++ b/web/app.js @@ -239,6 +239,7 @@ const PDFViewerApplication = { }, /** + * Potentially parse special debugging flags in the hash section of the URL. * @private */ async _parseHashParameters() { @@ -249,11 +250,12 @@ const PDFViewerApplication = { ) { return undefined; } - const waitOn = []; - - // Special debugging flags in the hash section of the URL. const hash = document.location.hash.substring(1); - const hashParams = parseQueryString(hash); + if (!hash) { + return undefined; + } + const hashParams = parseQueryString(hash), + waitOn = []; if ( "disableworker" in hashParams &&