Skip to content

Commit 4d87836

Browse files
committed
Implements preload option for scripts
1 parent ae7d5b8 commit 4d87836

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

webpack_loader/utils.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,14 @@ def get_as_tags(bundle_name, extension=None, config='DEFAULT', attrs='', is_prel
6262
tags = []
6363
for chunk in bundle:
6464
if chunk['name'].endswith(('.js', '.js.gz')):
65-
tags.append((
66-
'<script src="{0}" {1}></script>'
67-
).format(chunk['url'], attrs))
65+
if is_preload:
66+
tags.append((
67+
'<link rel="preload" as="script" href="{0}" {1}/>'
68+
).format(chunk['url'], attrs))
69+
else:
70+
tags.append((
71+
'<script src="{0}" {1}></script>'
72+
).format(chunk['url'], attrs))
6873
elif chunk['name'].endswith(('.css', '.css.gz')):
6974
tags.append((
7075
'<link href="{0}" rel={2} {1}/>'

0 commit comments

Comments
 (0)