def async_css(href):
"""
Outputs a link and noscript tag, which will asynchronously load an external stylesheet.
Sample usage::
<head>
...
{% async_css '/static/foo.css' %}
...
</head>
Results in::
<head>
...
<link rel="preload" href="/static/foo.css" onload="this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="/static/foo.css"></noscript>
...
</head>
"""
return format_html(''.join([
'<link rel="preload" href="{0}" as="style" onload="this.rel=\'stylesheet\'">',
'<noscript><link rel="stylesheet" href="{0}"></noscript>'
]), href)
评论列表
文章目录