html5-script-attribute "data-main" 是如何工作的?

How does html5-script-attribute "data-main" work?

例如 requireJS 使用以下语法:

<script data-main="scripts/main" src="scripts/require.js"></script>

在其文档中您可以阅读:

data-main attribute tells require.js to load scripts/main.js after require.js loads

  1. 那(脚本加载顺序)怎么可能?
  2. 如果 js 文件的名称是 nomain.js,数据属性会是 "data-nomain" 吗?
  3. 我在 html5 规范中没有看到相关信息,还是我看错地方了?

谢谢

How is that (script load-order) possible?

因为这就是 require.js 的目的,它由相当多的代码组成。

那个特定的部分相当微不足道,require.js 在它自己加载之前不能做任何事情(包括加载另一个脚本)。

If the name of the js-file was nomain.js, would the data-attribute be "data-nomain" ?

没有。 Require looks at data-main确定入口点脚本文件。它从该属性的值中获取 URL。

I see no information about that in the html5 specification or am I looking at wrong place?

data-* 属性在 3.2.5.9 Embedding custom non-visible data with the data-* attributes

部分定义