From 9619a1b583e20051054914fc18fb2a1997c58cb5 Mon Sep 17 00:00:00 2001
From: Dan Scott <dscott@laurentian.ca>
Date: Sun, 2 Apr 2017 10:45:00 -0400
Subject: [PATCH] LP#1411699: Make Dojo conditional for advanced search

While the copy locations filter is a core feature, it surfaces only in the
advanced search page. The current behaviour forces Dojo and all of its
dependencies to be loaded for every catalogue page.

By making it conditional on the advanced search page, we save approximately
600ms to first meaningful paint on the rest of the catalogue pages.

To test:

[1] Apply the two-patch series
[2] After applying the patch, verify that the copy location filter
    on the advance search page functions. Also verify that
    the JavaScript on the record details page that tweaks
    the visiblity of sub-tabs in the added content tab
    continue to work.
[3] Verify that other components that currently depend on Dojo,
    such as the ebook API, continue to work.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
---
 Open-ILS/src/templates/opac/parts/header.tt2 | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/Open-ILS/src/templates/opac/parts/header.tt2 b/Open-ILS/src/templates/opac/parts/header.tt2
index a0ffcb8fcf..f61db05f16 100644
--- a/Open-ILS/src/templates/opac/parts/header.tt2
+++ b/Open-ILS/src/templates/opac/parts/header.tt2
@@ -106,9 +106,10 @@
         END;
     END;
 
-    # Dojo is required to use the copy locations advanced search filter,
-    # therefore, it should always be enabled.
-    want_dojo = 1;
+    # Dojo is required for the copy locations advanced search filter
+    IF ctx.page == 'advanced';
+        want_dojo = 1;
+    END;
 
     use_autosuggest = ctx.get_cgf("opac.use_autosuggest");
 
-- 
2.11.0