perf: add defer to scripts and lazy loading to images
Some checks failed
CI / ruff (push) Successful in 14s
CI / validate (push) Has been cancelled
CI / dependency-scanning (push) Has been cancelled
CI / docs (push) Has been cancelled
CI / deploy (push) Has been cancelled
CI / pytest (push) Has been cancelled

Add defer attribute to 145 <script> tags across 103 template files
(PERF-067) and loading="lazy" to 22 <img> tags across 13 template
files (PERF-058). Both improve page load performance.

Validator totals: 0 errors, 2 warnings, 1360 info (down from 1527).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-16 20:55:52 +01:00
parent 3a7cf29386
commit 8ee8c398ce
110 changed files with 193 additions and 193 deletions

View File

@@ -8,7 +8,7 @@
{% block alpine_data %}backgroundTasks(){% endblock %}
{% block extra_scripts %}
<script src="{{ url_for('marketplace_static', path='admin/js/background-tasks.js') }}"></script>
<script defer src="{{ url_for('marketplace_static', path='admin/js/background-tasks.js') }}"></script>
{% endblock %}
{% block content %}

View File

@@ -11,7 +11,7 @@
{% block alpine_data %}adminImports(){% endblock %}
{% block extra_scripts %}
<script src="{{ url_for('marketplace_static', path='admin/js/imports.js') }}"></script>
<script defer src="{{ url_for('marketplace_static', path='admin/js/imports.js') }}"></script>
{% endblock %}
{% block content %}

View File

@@ -426,5 +426,5 @@
{% endblock %}
{% block extra_scripts %}
<script src="{{ url_for('marketplace_static', path='admin/js/letzshop-store-directory.js') }}"></script>
<script defer src="{{ url_for('marketplace_static', path='admin/js/letzshop-store-directory.js') }}"></script>
{% endblock %}

View File

@@ -11,7 +11,7 @@
{% block alpine_data %}adminLetzshop(){% endblock %}
{% block extra_scripts %}
<script src="{{ url_for('marketplace_static', path='admin/js/letzshop.js') }}"></script>
<script defer src="{{ url_for('marketplace_static', path='admin/js/letzshop.js') }}"></script>
{% endblock %}
{% block content %}

View File

@@ -599,5 +599,5 @@
document.head.appendChild(script);
})();
</script>
<script src="{{ url_for('marketplace_static', path='admin/js/marketplace-letzshop.js') }}"></script>
<script defer src="{{ url_for('marketplace_static', path='admin/js/marketplace-letzshop.js') }}"></script>
{% endblock %}

View File

@@ -50,7 +50,7 @@
<div class="px-4 py-3 bg-white rounded-lg shadow-md dark:bg-gray-800">
<div class="aspect-square bg-gray-100 dark:bg-gray-700 rounded-lg overflow-hidden">
<template x-if="product?.image_link">
<img :src="product?.image_link" :alt="product?.title" class="w-full h-full object-contain" />
<img loading="lazy" :src="product?.image_link" :alt="product?.title" class="w-full h-full object-contain" />
</template>
<template x-if="!product?.image_link">
<div class="w-full h-full flex items-center justify-center">
@@ -64,7 +64,7 @@
<div class="grid grid-cols-4 gap-2">
<template x-for="(img, index) in (product?.additional_images || [])" :key="index">
<div class="aspect-square bg-gray-100 dark:bg-gray-700 rounded overflow-hidden">
<img :src="img" :alt="'Image ' + (index + 1)" class="w-full h-full object-cover" />
<img loading="lazy" :src="img" :alt="'Image ' + (index + 1)" class="w-full h-full object-cover" />
</div>
</template>
</div>
@@ -388,5 +388,5 @@
{% endblock %}
{% block extra_scripts %}
<script src="{{ url_for('marketplace_static', path='admin/js/marketplace-product-detail.js') }}"></script>
<script defer src="{{ url_for('marketplace_static', path='admin/js/marketplace-product-detail.js') }}"></script>
{% endblock %}

View File

@@ -472,5 +472,5 @@
document.head.appendChild(script);
})();
</script>
<script src="{{ url_for('marketplace_static', path='admin/js/marketplace-products.js') }}"></script>
<script defer src="{{ url_for('marketplace_static', path='admin/js/marketplace-products.js') }}"></script>
{% endblock %}

View File

@@ -347,5 +347,5 @@
{% endblock %}
{% block extra_scripts %}
<script src="{{ url_for('marketplace_static', path='admin/js/marketplace.js') }}?v=2"></script>
<script defer src="{{ url_for('marketplace_static', path='admin/js/marketplace.js') }}?v=2"></script>
{% endblock %}

View File

@@ -9,7 +9,7 @@
{% block alpine_data %}storeLetzshop(){% endblock %}
{% block extra_scripts %}
<script src="/static/modules/marketplace/store/js/letzshop.js"></script>
<script defer src="/static/modules/marketplace/store/js/letzshop.js"></script>
{% endblock %}
{% block content %}

View File

@@ -11,7 +11,7 @@
{% block alpine_data %}storeMarketplace(){% endblock %}
{% block extra_scripts %}
<script src="/static/modules/marketplace/store/js/marketplace.js"></script>
<script defer src="/static/modules/marketplace/store/js/marketplace.js"></script>
{% endblock %}
{% block content %}

View File

@@ -373,11 +373,11 @@
</div>
<!-- Scripts -->
<script src="{{ url_for('static', path='shared/js/log-config.js') }}"></script>
<script src="{{ url_for('static', path='shared/js/icons.js') }}"></script>
<script src="{{ url_for('static', path='shared/js/utils.js') }}"></script>
<script src="{{ url_for('static', path='shared/js/api-client.js') }}"></script>
<script defer src="{{ url_for('static', path='shared/js/log-config.js') }}"></script>
<script defer src="{{ url_for('static', path='shared/js/icons.js') }}"></script>
<script defer src="{{ url_for('static', path='shared/js/utils.js') }}"></script>
<script defer src="{{ url_for('static', path='shared/js/api-client.js') }}"></script>
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.14.0/dist/cdn.min.js"></script>
<script src="{{ url_for('marketplace_static', path='store/js/onboarding.js') }}"></script>
<script defer src="{{ url_for('marketplace_static', path='store/js/onboarding.js') }}"></script>
</body>
</html>