首页 > 解决方案 > 如何在具有 document.write 的 DIV 元素中异步加载 js 内容?

问题描述

我有jsfile.js包含代码的js 文件

document.write('<script>..</script><style>..</style><a></a><script src".."></script>');

document.write() 中的代码实际上是一个示例网页的 html 文档,其中包含脚本、样式、元数据和所有其他可能的元素。

在没有渲染阻塞的情况下,如何在网页中加载jsfile.js内部元素?div

我目前使用<script src="https://example.com/jsfile.js"></script>,但它会渲染块下面的其他内容script

标签: javascripthtmldocument.write

解决方案


推荐阅读