aboutsummaryrefslogtreecommitdiffstats
path: root/templates/web/base/common_scripts.html
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2017-11-14 16:23:11 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-11-15 16:02:26 +0000
commitf59e12ee3fa9c65f178a300954586f6ac91bba79 (patch)
treee28721f5b356f5b916e59811a192cc96cc32ac4c /templates/web/base/common_scripts.html
parent865df7790d20ffbeacd8dd10316f4a7f733dcb1d (diff)
Have front page load minimal JS necessary.
By creating a small file with only what is needed (focus, js flagging), we can drop loading jQuery and all the application JavaScript on the front page, prefetching them instead.
Diffstat (limited to 'templates/web/base/common_scripts.html')
-rw-r--r--templates/web/base/common_scripts.html14
1 files changed, 11 insertions, 3 deletions
diff --git a/templates/web/base/common_scripts.html b/templates/web/base/common_scripts.html
index b04404f06..c6225e8fa 100644
--- a/templates/web/base/common_scripts.html
+++ b/templates/web/base/common_scripts.html
@@ -7,15 +7,14 @@ scripts = [];
scripts.push(
start _ "/js/translation_strings." _ lang_code _ ".js?" _ Math.int( date.now / 3600 ),
- version('/jslib/jquery-1.7.2.min.js'),
- version('/js/jquery.multi-select.js'),
- version('/cobrands/fixmystreet/fixmystreet.js'),
);
+SET jquery_loaded = 0;
SET geolocation_loaded = 0;
IF bodyclass.match('frontpage');
SET geolocation_loaded = 1;
scripts.push(
+ version('/js/front.js'),
version('/js/geolocation.js'),
);
ELSIF bodyclass.match('alertpage');
@@ -24,9 +23,13 @@ ELSIF bodyclass.match('alertpage');
version('/js/geolocation.js'),
);
ELSE;
+ SET jquery_loaded = 1;
scripts.push(
version('/js/validation_rules.js'),
+ version('/jslib/jquery-1.7.2.min.js'),
+ version('/js/jquery.multi-select.js'),
version('/vendor/jquery.validate.min.js'),
+ version('/cobrands/fixmystreet/fixmystreet.js'),
);
END;
@@ -40,6 +43,11 @@ IF c.user_exists AND (c.user.from_body OR c.user.is_superuser);
version('/js/geolocation.js'),
);
END;
+ IF NOT jquery_loaded;
+ scripts.push(
+ version('/jslib/jquery-1.7.2.min.js'),
+ );
+ END;
scripts.push(
version('/cobrands/fixmystreet/staff.js')
);