Skip to content

Commit

Permalink
Implements preload option for scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
joaopslins committed Aug 16, 2021
1 parent ae7d5b8 commit 4d87836
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions webpack_loader/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,14 @@ def get_as_tags(bundle_name, extension=None, config='DEFAULT', attrs='', is_prel
tags = []
for chunk in bundle:
if chunk['name'].endswith(('.js', '.js.gz')):
tags.append((
'<script src="{0}" {1}></script>'
).format(chunk['url'], attrs))
if is_preload:
tags.append((
'<link rel="preload" as="script" href="{0}" {1}/>'
).format(chunk['url'], attrs))
else:
tags.append((
'<script src="{0}" {1}></script>'
).format(chunk['url'], attrs))
elif chunk['name'].endswith(('.css', '.css.gz')):
tags.append((
'<link href="{0}" rel={2} {1}/>'
Expand Down

0 comments on commit 4d87836

Please sign in to comment.