-
Notifications
You must be signed in to change notification settings - Fork 596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for type=module & attr nomodule #1006
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<link rel="stylesheet" href="{{ compressed.url }}" type="text/css"{% if compressed.media %} media="{{ compressed.media }}"{% endif %}> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<script type="module" src="{{ compressed.url }}"{{ compressed.extra }}></script> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ Usage | |
.. code-block:: django | ||
|
||
{% load compress %} | ||
{% compress <js/css> [<file/inline/preload> [block_name]] %} | ||
{% compress <js/css> [<file/inline/preload/nomodule> [block_name]] %} | ||
<html of inline or linked JS/CSS> | ||
{% endcompress %} | ||
|
||
|
@@ -63,6 +63,33 @@ Result: | |
<link rel="preload" href="/static/CACHE/js/d01466eb4fc6.js" as="script" /> | ||
|
||
|
||
|
||
ES5 nomodule & ES6 type="module" | ||
|
||
Adding the ``nomodule`` attribute will generate be passed attribute to the script tag for the compressed resource in the template. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That sentence didn't quite parse for me :) |
||
Adding the ``module`` parameter will generate the script tag with type="module" for the compressed resource in the template: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd suggest clarifying that |
||
|
||
.. code-block:: django | ||
|
||
{% compress js %} | ||
<!-- ES5 must be in separate compress (split types) --> | ||
<script nomodule async src="static/js/es5.js"></script> | ||
{% endcompress %} | ||
|
||
{% compress js module %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be better if this supported the |
||
<!-- ES6 and above JS --> | ||
<script async src="static/js/es6.js"></script> | ||
{% endcompress %} | ||
|
||
Result: | ||
|
||
.. code-block:: django | ||
|
||
<script nomodule async src="/static/CACHE/js/d01466eb4fc6.js"></script> | ||
<script type="module" async src="/static/CACHE/js/d0246230b4fc6.js"></script> | ||
|
||
|
||
|
||
Specifying a ``block_name`` will change the output filename. It can also be | ||
accessed in the :ref:`post_compress signal <signals>` in the ``context`` parameter. | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't that be
module
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nomodule
is an attribute itself, butmodule
is atype
attribute option - they have a relationship but they are not the samethis is for how the library strips all attributes