landing_utils.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:site 作者: alphageek-xyz 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号