【发布时间】:2019-08-18 08:46:28
【问题描述】:
如何使用 loadCSS (https://github.com/filamentgroup/loadCSS) 加载我的样式表?
目前我正在将带有类似模板标签的 loadCSS javascript 包含在我的脑海中。我只是用 noscript 标签包围了我的默认 css 作为后备(如文档中所述)。
<head>
...
<noscript>
{% stylesheet "main" %}
</noscript>
...
<script>
{% include "components/loadCSS.js" %}
</script>
...
</head>
但是我怎样才能生成这样的输出呢?
<link rel="preload" href="path/to/mystylesheet.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
我能否以某种方式在我的模板中获取链接(在 href 内)?
【问题讨论】:
标签: css django-pipeline