Add preconnect headers for goatcounter and plausible

This commit is contained in:
Gabriel Augendre 2021-01-04 23:02:48 +01:00
parent 2bbdef77a3
commit 9958b37699
No known key found for this signature in database
GPG key ID: 1E693F4CE4AEE7B4
3 changed files with 27 additions and 15 deletions

View file

@ -9,6 +9,7 @@
<meta name="color-scheme" content="light dark">
<title>{% block title %}Home | {% endblock %}{{ blog_title }} by {{ blog_author }}</title>
<link rel="alternate" type="application/rss+xml" title="Gab's Notes » Feed" href="{% url 'complete-feed' %}">
{% include "articles/snippets/analytics_head.html" %}
{% include "articles/snippets/page_metadata.html" %}
{% compress css inline %}

View file

@ -1,19 +1,21 @@
{% load static compress %}
{% if plausible_domain is not None and not user.is_authenticated %}
<script async defer data-domain="{{ plausible_domain }}"
src="https://plausible.augendre.info/js/plausible.js">
</script>
{% endif %}
{% compress js inline %}
{% if goatcounter_domain is not None and not user.is_authenticated %}
<script>
window.goatcounter = {
endpoint: 'https://{{ goatcounter_domain }}/count',
allow_local: true,
}
{% if not user.is_authenticated %}
{% if plausible_domain is not None %}
<script async defer data-domain="{{ plausible_domain }}"
src="https://plausible.augendre.info/js/plausible.js">
</script>
<script async defer src="{% static "vendor/goatcounter.js" %}"></script>
{% endif %}
{% endcompress %}
{% compress js inline %}
{% if goatcounter_domain is not None %}
<script>
window.goatcounter = {
endpoint: 'https://{{ goatcounter_domain }}/count',
allow_local: true,
}
</script>
<script async defer src="{% static "vendor/goatcounter.js" %}"></script>
{% endif %}
{% endcompress %}
{% endif %}

View file

@ -0,0 +1,9 @@
{% if not user.is_authenticated %}
{% if plausible_domain is not None %}
<link rel="preconnect" href="https://plausible.augendre.info">
{% endif %}
{% if goatcounter_domain is not None %}
<link rel="preconnect" href="https://{{ goatcounter_domain }}">
{% endif %}
{% endif %}