diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-08-15 11:43:21 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-08-16 18:38:23 +0100 |
commit | bef9203e2380df25372e3f8aa7c763a72ec4aa5a (patch) | |
tree | 8c57cf70250ca279d43bf4b1cf77731a151c9a28 | |
parent | 3425a7ba037612141f75321d3d0b226e4ca0ed1e (diff) |
Move most JavaScript to end, inline the remaining.
30 files changed, 71 insertions, 69 deletions
diff --git a/templates/web/angus/footer.html b/templates/web/angus/footer.html index a09c7ce2f..9a7e1dd6d 100644 --- a/templates/web/angus/footer.html +++ b/templates/web/angus/footer.html @@ -9,8 +9,6 @@ </div> </div> </div> - -<!-- [% INCLUDE 'debug_footer.html' %] --> </div> <!-- .wrapper --> [% IF pagefooter %] @@ -21,7 +19,7 @@ </div> [% END %] - [% TRY %][% PROCESS 'footer_extra.html' %][% CATCH file %][% END %] + [% INCLUDE 'common_footer_tags.html' %] </body> </html> diff --git a/templates/web/base/common_footer_tags.html b/templates/web/base/common_footer_tags.html new file mode 100644 index 000000000..302d802d0 --- /dev/null +++ b/templates/web/base/common_footer_tags.html @@ -0,0 +1,32 @@ +[% USE date %][% USE Math %] + +[% TRY %][% PROCESS 'footer_extra.html' %][% CATCH file %][% END %] + +<script type="text/javascript" src="[% start %]/js/translation_strings.[% lang_code %].js?[% Math.int( date.now / 3600 ) %]"></script> +<script type="text/javascript" src="[% version('/jslib/jquery-1.7.2.min.js') %]"></script> +<!--[if lte IE 9]> + <script type="text/javascript" src="[% version('/js/history.polyfill.min.js') %]"></script> +<![endif]--> +<script type="text/javascript" src="[% version('/js/validation_rules.js') %]"></script> +<script src="[% version('/js/jquery.validate.min.js') %]" type="text/javascript" charset="utf-8"></script> +<script type="text/javascript" src="[% version('/js/dropzone.min.js') %]"></script> + +[% map_js %] +<script src="[% version('/cobrands/fixmystreet/map.js') %]"></script> + +<script type="text/javascript" src="[% version('/js/geo.min.js') %]"></script> +<script type="text/javascript" src="[% version('/cobrands/fixmystreet/fixmystreet.js') %]"></script> + +[% IF admin %] + <script src="[% version('/js/jquery-ui/js/jquery-ui-1.10.3.custom.min.js') %]"></script> + <script type="text/javascript" src="[% version('/js/fixmystreet-admin.js') %]"></script> +[% END %] + +[% moderating = c.user && c.user.has_permission_to('moderate', problem.bodies_str) %] +[% IF moderating %] + <script type="text/javascript" src="[% version('/js/moderate.js') %]"></script> +[% END %] + +[% extra_js %] + +[% TRY %][% PROCESS 'footer_extra_js.html' %][% CATCH file %][% END %] diff --git a/templates/web/base/common_header_tags.html b/templates/web/base/common_header_tags.html index 7f81a020c..24d2f11e5 100644 --- a/templates/web/base/common_header_tags.html +++ b/templates/web/base/common_header_tags.html @@ -1,4 +1,3 @@ -[% USE date %][% USE Math %] [% SET start = c.config.ADMIN_BASE_URL IF admin %] <meta http-equiv="content-type" content="text/html; charset=utf-8" @@ -8,35 +7,16 @@ <!--[if (lt IE 9)]> <script src="[% version('/js/html5shiv.js') %]""></script> <![endif]--> -<script src="[% version('/js/modernizr.custom.js') %]" charset="utf-8"></script> -<script src="[% version('/cobrands/fixmystreet/header.js') %]"></script> -<script type="text/javascript" src="[% start %]/js/translation_strings.[% lang_code %].js?[% Math.int( date.now / 3600 ) %]"></script> - -<script type="text/javascript" src="[% version('/jslib/jquery-1.7.2.min.js') %]"></script> -<!--[if lte IE 9]> - <script type="text/javascript" src="[% version('/js/history.polyfill.min.js') %]"></script> -<![endif]--> -<script type="text/javascript" src="[% version('/js/validation_rules.js') %]"></script> -<script src="[% version('/js/jquery.validate.min.js') %]" type="text/javascript" charset="utf-8"></script> -<script type="text/javascript" src="[% version('/js/dropzone.min.js') %]"></script> - -<script type="text/javascript" src="[% version('/js/geo.min.js') %]"></script> -<script type="text/javascript" src="[% version('/cobrands/fixmystreet/fixmystreet.js') %]"></script> +<script> + window.Modernizr=function(e,t,n){function r(e){p.cssText=e}function o(e,t){return typeof e===t}var a,i,c,l="2.8.3",s={},u=t.documentElement,d="modernizr",f=t.createElement(d),p=f.style,m=({}.toString,{}),h=[],y=h.slice,v=function(e,n,r,o){var a,i,c,l,s=t.createElement("div"),f=t.body,p=f||t.createElement("body");if(parseInt(r,10))for(;r--;)c=t.createElement("div"),c.id=o?o[r]:d+(r+1),s.appendChild(c);return a=["­",'<style id="s',d,'">',e,"</style>"].join(""),s.id=d,(f?s:p).innerHTML+=a,p.appendChild(s),f||(p.style.background="",p.style.overflow="hidden",l=u.style.overflow,u.style.overflow="hidden",u.appendChild(p)),i=n(s,e),f?s.parentNode.removeChild(s):(p.parentNode.removeChild(p),u.style.overflow=l),!!i},g=function(t){var n=e.matchMedia||e.msMatchMedia;if(n)return n(t)&&n(t).matches||!1;var r;return v("@media "+t+" { #"+d+" { position: absolute; } }",function(t){r="absolute"==(e.getComputedStyle?getComputedStyle(t,null):t.currentStyle).position}),r},b={}.hasOwnProperty;c=o(b,"undefined")||o(b.call,"undefined")?function(e,t){return t in e&&o(e.constructor.prototype[t],"undefined")}:function(e,t){return b.call(e,t)};for(var E in m)c(m,E)&&(i=E.toLowerCase(),s[i]=m[E](),h.push((s[i]?"":"no-")+i));return r(""),f=a=null,s._version=l,s.mq=g,s.testStyles=v,s}(this,this.document); + var fixmystreet=fixmystreet||{}; + (function(b){var a=b.documentElement;a.className=a.className.replace(/\bno-js\b/,"js");var c=-1<a.className.indexOf("iel8"),c=Modernizr.mq("(min-width: 48em)")||c?"desktop":"mobile";b=b.getElementById("js-meta-data");fixmystreet.page=b.getAttribute("data-page");fixmystreet.cobrand=b.getAttribute("data-cobrand");"mobile"==c&&(a.className+=" mobile","around"==fixmystreet.page&&(a.className+=" mobile-reporting-map only-map"))})(document); +</script> [% IF admin %] - <script src="[% version('/js/jquery-ui/js/jquery-ui-1.10.3.custom.min.js') %]"></script> <link rel="stylesheet" href="[% version('/js/jquery-ui/css/smoothness/jquery-ui-1.10.3.custom.min.css') %]"> - <script type="text/javascript" src="[% version('/js/fixmystreet-admin.js') %]"></script> [% END %] -[% moderating = c.user && c.user.has_permission_to('moderate', problem.bodies_str) %] -[% IF moderating %] - <script type="text/javascript" src="[% version('/js/moderate.js') %]"></script> -[% END %] - -[% map_js %] -[% extra_js %] - [% IF robots %] <meta name="robots" content="[% robots %]"> [% ELSIF c.config.STAGING_SITE %] diff --git a/templates/web/base/footer.html b/templates/web/base/footer.html index d046d6297..0356840da 100644 --- a/templates/web/base/footer.html +++ b/templates/web/base/footer.html @@ -40,11 +40,9 @@ </div> </div> </div> - -<!-- [% INCLUDE 'debug_footer.html' %] --> </div> <!-- .wrapper --> - [% TRY %][% PROCESS 'footer_extra.html' %][% CATCH file %][% END %] + [% INCLUDE 'common_footer_tags.html' %] </body> </html> diff --git a/templates/web/base/maps/openlayers.html b/templates/web/base/maps/openlayers.html index b9dc0747c..bc71847ad 100644 --- a/templates/web/base/maps/openlayers.html +++ b/templates/web/base/maps/openlayers.html @@ -30,7 +30,6 @@ <div id="map"> [% INCLUDE 'maps/noscript_map.html' js = 1 %] </div> - <script src="[% version('/cobrands/fixmystreet/map.js') %]"></script> [% IF map.copyright %] <div class="olControlAttribution" style="position: absolute;">[% map.copyright %]</div> [% END %] diff --git a/templates/web/bristol/footer.html b/templates/web/bristol/footer.html index 1701aa805..c71d7151b 100644 --- a/templates/web/bristol/footer.html +++ b/templates/web/bristol/footer.html @@ -28,8 +28,6 @@ </div> </div> </div> - -<!-- [% INCLUDE 'debug_footer.html' %] --> </div> <!-- .wrapper --> [% IF pagefooter %] @@ -40,7 +38,7 @@ </div> [% END %] - [% TRY %][% PROCESS 'footer_extra.html' %][% CATCH file %][% END %] + [% INCLUDE 'common_footer_tags.html' %] </body> </html> diff --git a/templates/web/fixmystreet-uk-councils/header_extra.html b/templates/web/bristol/footer_extra_js.html index cf8fa7301..cf8fa7301 100644 --- a/templates/web/fixmystreet-uk-councils/header_extra.html +++ b/templates/web/bristol/footer_extra_js.html diff --git a/templates/web/bristol/header_extra.html b/templates/web/bristol/header_extra.html index fd20823ae..8a977495f 100644 --- a/templates/web/bristol/header_extra.html +++ b/templates/web/bristol/header_extra.html @@ -1,2 +1 @@ -<script src="[% version('/cobrands/fixmystreet-uk-councils/js.js') %]"></script> [% INCLUDE 'tracking_code.html' %] diff --git a/templates/web/bromley/footer.html b/templates/web/bromley/footer.html index 87d244480..37ba0641e 100644 --- a/templates/web/bromley/footer.html +++ b/templates/web/bromley/footer.html @@ -25,10 +25,9 @@ </div> </div> </div> - </div> <!-- .wrapper --> - [% TRY %][% PROCESS 'footer_extra.html' %][% CATCH file %][% END %] + [% INCLUDE 'common_footer_tags.html' %] </body> </html> diff --git a/templates/web/bromley/header_extra.html b/templates/web/bromley/footer_extra_js.html index 57066dbe8..57066dbe8 100644 --- a/templates/web/bromley/header_extra.html +++ b/templates/web/bromley/footer_extra_js.html diff --git a/templates/web/eastherts/footer.html b/templates/web/eastherts/footer.html index b0e5e0ae0..b665153bd 100644 --- a/templates/web/eastherts/footer.html +++ b/templates/web/eastherts/footer.html @@ -32,8 +32,6 @@ </div> </div> </div> - -<!-- [% INCLUDE 'debug_footer.html' %] --> </div> <!-- .wrapper --> [% IF pagefooter %] @@ -50,7 +48,7 @@ </footer> [% END %] - [% TRY %][% PROCESS 'footer_extra.html' %][% CATCH file %][% END %] + [% INCLUDE 'common_footer_tags.html' %] </body> </html> diff --git a/templates/web/fiksgatami/footer.html b/templates/web/fiksgatami/footer.html index 8bc9f5d4f..097fe82e1 100644 --- a/templates/web/fiksgatami/footer.html +++ b/templates/web/fiksgatami/footer.html @@ -29,8 +29,9 @@ </div> </div> </div> - -<!-- [% INCLUDE 'debug_footer.html' %] --> </div> <!-- .wrapper --> + + [% INCLUDE 'common_footer_tags.html' %] + </body> </html> diff --git a/templates/web/fixamingata/footer.html b/templates/web/fixamingata/footer.html index 5364c0b60..fc3cf02f0 100644 --- a/templates/web/fixamingata/footer.html +++ b/templates/web/fixamingata/footer.html @@ -26,9 +26,10 @@ </div> </div> </div> - -<!-- [% INCLUDE 'debug_footer.html' %] --> </div> <!-- .wrapper --> + + [% INCLUDE 'common_footer_tags.html' %] + <script type="text/javascript"> var uvOptions = {}; (function() { diff --git a/templates/web/fixmystreet-uk-councils/footer_extra_js.html b/templates/web/fixmystreet-uk-councils/footer_extra_js.html new file mode 100644 index 000000000..cf8fa7301 --- /dev/null +++ b/templates/web/fixmystreet-uk-councils/footer_extra_js.html @@ -0,0 +1 @@ +<script src="[% version('/cobrands/fixmystreet-uk-councils/js.js') %]"></script> diff --git a/templates/web/fixmystreet.com/footer_extra_js.html b/templates/web/fixmystreet.com/footer_extra_js.html new file mode 100644 index 000000000..47733ef8e --- /dev/null +++ b/templates/web/fixmystreet.com/footer_extra_js.html @@ -0,0 +1,2 @@ +<script src="[% version('/js/jquery.cookie.min.js') %]"></script> +<script src="[% version('/cobrands/fixmystreet.com/js.js') %]"></script> diff --git a/templates/web/fixmystreet.com/header_extra.html b/templates/web/fixmystreet.com/header_extra.html index 08f1251aa..442a87e72 100644 --- a/templates/web/fixmystreet.com/header_extra.html +++ b/templates/web/fixmystreet.com/header_extra.html @@ -1,9 +1,6 @@ <meta name='theme-color' content='#ffd000'> <link rel="Shortcut Icon" type="image/x-icon" href="/cobrands/fixmystreet.com/favicon.ico"> -<script src="[% version('/js/jquery.cookie.min.js') %]"></script> -<script src="[% version('/cobrands/fixmystreet.com/js.js') %]"></script> - [%# We are conducting an A/B experiment %] [% IF c.config.BASE_URL == "https://www.fixmystreet.com" AND not admin %] <script src="//www.google-analytics.com/cx/api.js?experiment=ZwMlZkAhSbK_tP_QG64QrQ"></script> diff --git a/templates/web/greenwich/footer.html b/templates/web/greenwich/footer.html index a7c939358..494d5b66b 100644 --- a/templates/web/greenwich/footer.html +++ b/templates/web/greenwich/footer.html @@ -27,10 +27,9 @@ </div> </div> </div> - </div> <!-- .wrapper --> - [% TRY %][% PROCESS 'footer_extra.html' %][% CATCH file %][% END %] + [% INCLUDE 'common_footer_tags.html' %] </body> </html> diff --git a/templates/web/harrogate/footer.html b/templates/web/harrogate/footer.html index 716068b14..47eef161b 100644 --- a/templates/web/harrogate/footer.html +++ b/templates/web/harrogate/footer.html @@ -9,8 +9,6 @@ </div> </div> </div> - -<!-- [% INCLUDE 'debug_footer.html' %] --> </div> <!-- .wrapper --> [% IF pagefooter %] @@ -37,5 +35,7 @@ </footer> [% END %] + [% INCLUDE 'common_footer_tags.html' %] + </body> </html> diff --git a/templates/web/hart/footer.html b/templates/web/hart/footer.html index 312f63ff4..fae5bed1a 100644 --- a/templates/web/hart/footer.html +++ b/templates/web/hart/footer.html @@ -104,6 +104,7 @@ <div class="footer_border"> </div> + [% INCLUDE 'common_footer_tags.html' %] </div> </body> diff --git a/templates/web/hart/header.html b/templates/web/hart/header.html index c549c41ee..ee29df818 100644 --- a/templates/web/hart/header.html +++ b/templates/web/hart/header.html @@ -24,8 +24,6 @@ <link rel="Shortcut Icon" type="image/x-icon" href="/cobrands/hart/favicon.ico"> - [% PROCESS 'header_extra.html' %] - </head> [% TRY %][% PROCESS 'set_body_class.html' %][% CATCH file %][% END %] <body class="[% bodyclass | html IF bodyclass %]"> diff --git a/templates/web/oxfordshire/footer.html b/templates/web/oxfordshire/footer.html index 26bdf7ab2..d004de591 100644 --- a/templates/web/oxfordshire/footer.html +++ b/templates/web/oxfordshire/footer.html @@ -29,8 +29,6 @@ </div> </div> </div> - -<!-- [% INCLUDE 'debug_footer.html' %] --> </div> <!-- .wrapper --> <div id="oxford-footer" class="desk-only"> <address> @@ -45,5 +43,8 @@ </ul> </div> </div> <!-- oxford-wrapper --> + + [% INCLUDE 'common_footer_tags.html' %] + </body> </html> diff --git a/templates/web/oxfordshire/header.html b/templates/web/oxfordshire/header.html index ebacf9e6a..6878f491a 100644 --- a/templates/web/oxfordshire/header.html +++ b/templates/web/oxfordshire/header.html @@ -20,8 +20,6 @@ [% INCLUDE 'common_header_tags.html' %] [% INCLUDE 'tracking_code.html' %] - [% PROCESS 'header_extra.html' %] - </head> <body class="[% bodyclass | html IF bodyclass %]"> <div id="oxford-wrapper"> diff --git a/templates/web/seesomething/footer.html b/templates/web/seesomething/footer.html index c29f222d2..555a01010 100644 --- a/templates/web/seesomething/footer.html +++ b/templates/web/seesomething/footer.html @@ -15,8 +15,9 @@ </div> </div> </div> - -<!-- [% INCLUDE 'debug_footer.html' %] --> </div> <!-- .wrapper --> + + [% INCLUDE 'common_footer_tags.html' %] + </body> </html> diff --git a/templates/web/stevenage/footer.html b/templates/web/stevenage/footer.html index 3fcd9b5a1..e251a83c2 100644 --- a/templates/web/stevenage/footer.html +++ b/templates/web/stevenage/footer.html @@ -105,8 +105,9 @@ </div> </div> </div> - -<!-- [% INCLUDE 'debug_footer.html' %] --> </div> <!-- .wrapper --> + + [% INCLUDE 'common_footer_tags.html' %] + </body> </html> diff --git a/templates/web/stevenage/header.html b/templates/web/stevenage/header.html index f5d68eabe..34f5ba2b2 100644 --- a/templates/web/stevenage/header.html +++ b/templates/web/stevenage/header.html @@ -20,7 +20,6 @@ [% INCLUDE 'common_header_tags.html' %] [% INCLUDE 'tracking_code.html' %] - [% PROCESS 'header_extra.html' %] </head> <body class="[% bodyclass | html IF bodyclass %]"> diff --git a/templates/web/warwickshire/footer.html b/templates/web/warwickshire/footer.html index 35c1ae8ec..a22c66200 100644 --- a/templates/web/warwickshire/footer.html +++ b/templates/web/warwickshire/footer.html @@ -37,5 +37,6 @@ </div> </footer> <!-- Fin. --> + [% INCLUDE 'common_footer_tags.html' %] </body> </html> diff --git a/templates/web/warwickshire/header.html b/templates/web/warwickshire/header.html index d55e27dba..3c74b6d0e 100644 --- a/templates/web/warwickshire/header.html +++ b/templates/web/warwickshire/header.html @@ -26,8 +26,6 @@ <![endif]--> [% INCLUDE 'common_header_tags.html' %] - - [% PROCESS 'header_extra.html' %] </head> [% TRY %][% PROCESS 'set_body_class.html' %][% CATCH file %][% END %] diff --git a/templates/web/zurich/footer.html b/templates/web/zurich/footer.html index 11bfa9fcb..c5f7685a0 100644 --- a/templates/web/zurich/footer.html +++ b/templates/web/zurich/footer.html @@ -25,8 +25,6 @@ </div> </div> </div> - -<!-- [% INCLUDE 'debug_footer.html' %] --> </div> <!-- .wrapper --> <div id="zurich-footer-wrapper" class="desk-only"> @@ -37,5 +35,7 @@ </div> </div> + [% INCLUDE 'common_footer_tags.html' %] + </body> </html> diff --git a/web/cobrands/fixmystreet/front.js b/web/cobrands/fixmystreet/front.js index 8fc5db214..a5e3bac98 100644 --- a/web/cobrands/fixmystreet/front.js +++ b/web/cobrands/fixmystreet/front.js @@ -3,10 +3,10 @@ yepnope.addPrefix( 'preload', function ( resource ) { return resource; }); -$(function(){ +(function(){ var scripts = document.getElementById('script_front').getAttribute('data-scripts').split(','); for (var i=0; i<scripts.length; i++) { scripts[i] = 'preload!' + scripts[i]; } yepnope({ load: scripts }); -}); +})(); diff --git a/web/cobrands/fixmystreet/header.js b/web/cobrands/fixmystreet/header.js index 493facc7d..c4c3de1b6 100644 --- a/web/cobrands/fixmystreet/header.js +++ b/web/cobrands/fixmystreet/header.js @@ -1,3 +1,5 @@ +// A minimized version of this is inline in the header. + var fixmystreet = fixmystreet || {}; (function(D){ |