Skip to content

Commit 4463d30

Browse files
committed
Improve perf: css/js to end; templating for goatcounter src
Lighthouse reports a lot of time was spent waiting for js and css to load before page could be shown. Especially for customizing.html. Keep style.css in head, but move pygments.css to end of body. (note, lighthouse was reporting that contrast for pygments wasn;t as high as it should be.) Also move the 4 js files: jquery, underscore.js, doctools.js language_data.js to the end of body. Move the js script that shows the searchbox there too as it uses jquery. Use the templating pathto() function to generate path to goatcounter js file.
1 parent d81b51a commit 4463d30

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

website/www/_templates/layout.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
{%- endfor %}
2020
{%- else %}
2121
<link rel="stylesheet" href="{{ pathto('_static/style.css', 1) }}" type="text/css" />
22-
<link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}" type="text/css" />
2322

2423
{%- endif %}
2524
{%- if builder != 'htmlhelp' %}
@@ -31,9 +30,6 @@
3130
FILE_SUFFIX: '{{ file_suffix }}'
3231
};
3332
</script>
34-
{%- for scriptfile in script_files %}
35-
<script type="text/javascript" src="{{ pathto(scriptfile, 1) }}"></script>
36-
{%- endfor %}
3733
{%- if pageurl %}
3834
<link rel="canonical" href="{{ pageurl|e }}" />
3935
{%- endif %}
@@ -80,7 +76,6 @@
8076
<input type="hidden" name="area" value="default" />
8177
</form>
8278
</div>
83-
<script type="text/javascript">$('#searchbox').show(0);</script>
8479
{%- endif %}
8580
</div>
8681
<div class="navigation">
@@ -123,6 +118,7 @@
123118
</div>
124119
</div>
125120
{%- endblock %}
121+
<link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}" type="text/css" />
126122
<script>
127123
/* locally hosted goatcounter https://www.goatcounter.com/ */
128124
/* include site info in path url to allow multiple sites to be
@@ -133,7 +129,11 @@
133129
</script>
134130
<script data-goatcounter="https://stats.rouilj.dynamic-dns.net/count"
135131
integrity="sha384-QGgNMMRFTi8ul5kHJ+vXysPe8gySvSA/Y3rpXZiRLzKPIw8CWY+a3ObKmQsyDr+a"
136-
async="" src="_static/goatcounter_count.v3.js">
132+
async="" src="{{ pathto('_static/goatcounter_count.v3.js', 1) }}">
137133
</script>
134+
{%- for scriptfile in script_files %}
135+
<script type="text/javascript" src="{{ pathto(scriptfile, 1) }}"></script>
136+
{%- endfor %}
137+
<script type="text/javascript">$('#searchbox').show(0);</script>
138138
</body>
139139
</html>

0 commit comments

Comments
 (0)