django-vite: Script tag shouldn’t have defer, possibly nor async
The defer
and async
are added to the script tag:
<script type="module" async="" defer="" src="/static/app.f0505013.js"></script>
However, the defer
attribute is implied by browsers that support type="module"
, so it shouldn’t be added.
Regarding async
, it seems it might block the parsing of the DOM to execute the code as soon as possible, out of order.
IMHO it would be better to remove it, or leave the lib user to add it.
Resource: https://gist.github.com/jakub-g/385ee6b41085303a53ad92c7c8afd7a6
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (13 by maintainers)
Commits related to this issue
- Allow to set scripts_attrs also for in DJANGO_VITE_DEV_MODE (MrBin99/django-vite#24) — committed to trepmag/django-vite by trepmag 2 years ago
- Allow to set scripts_attrs also for in DJANGO_VITE_DEV_MODE (MrBin99/django-vite#24) — committed to trepmag/django-vite by trepmag 2 years ago
Sorry I’m an idiot 😅 I forgot that we are talking about modules … I’ll fix that.
Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#other_differences_between_modules_and_standard_scripts
Hi, i’m currently working on a version 2.0 of Django Vite, it will make easier to customize async, defer and custom attributes. It will also support pathlib.Path sor settings.
Stay tune.
Hello, for info, with the patch 9402410 and the template tag bellow the script tag can be inserted by specifying any attribute the user needs; e.g.:
Template tag:
Exactly, great! I’ll work on it on the next days.