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"> <meta name="color-scheme" content="light dark">
<title>{% block title %}Home | {% endblock %}{{ blog_title }} by {{ blog_author }}</title> <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' %}"> <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" %} {% include "articles/snippets/page_metadata.html" %}
{% compress css inline %} {% compress css inline %}

View file

@ -1,13 +1,14 @@
{% load static compress %} {% load static compress %}
{% if plausible_domain is not None and not user.is_authenticated %} {% if not user.is_authenticated %}
{% if plausible_domain is not None %}
<script async defer data-domain="{{ plausible_domain }}" <script async defer data-domain="{{ plausible_domain }}"
src="https://plausible.augendre.info/js/plausible.js"> src="https://plausible.augendre.info/js/plausible.js">
</script> </script>
{% endif %} {% endif %}
{% compress js inline %} {% compress js inline %}
{% if goatcounter_domain is not None and not user.is_authenticated %} {% if goatcounter_domain is not None %}
<script> <script>
window.goatcounter = { window.goatcounter = {
endpoint: 'https://{{ goatcounter_domain }}/count', endpoint: 'https://{{ goatcounter_domain }}/count',
@ -17,3 +18,4 @@
<script async defer src="{% static "vendor/goatcounter.js" %}"></script> <script async defer src="{% static "vendor/goatcounter.js" %}"></script>
{% endif %} {% endif %}
{% endcompress %} {% 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 %}