MathJax中配置选项中有趣的javascript代码

MathJax中配置选项中有趣的javascript代码,javascript,configuration,mathjax,Javascript,Configuration,Mathjax,据我所知,javascript代码可以“定义”为文件 或者作为内联代码 <script type="text/javascript"> .... // some more code .... </script> .... //还有代码吗 .... 那么,这是如何做到的呢?然而,这是javascript代码 <script type="text/javascript" src="MathJax.js"> MathJax.Hub.Config({

据我所知,javascript代码可以“定义”为文件


或者作为内联代码

<script type="text/javascript">
....
// some more code
....
</script>

....
//还有代码吗
....
那么,这是如何做到的呢?然而,这是javascript代码

<script type="text/javascript" src="MathJax.js">
   MathJax.Hub.Config({
      extensions: ["tex2jax.js", "mml2jax.js"],
      jax: ["input/Tex", "input/MathML", "output/HTML-CSS"]
   });
</script>

MathJax.Hub.Config({
扩展:[“tex2jax.js”、“mml2jax.js”],
jax:[“input/Tex”、“input/MathML”、“output/HTML-CSS”]
});

配置MathJax这只是一些无效的标记。规范摘录如下(注意必须而非应该的用法):

如果未设置src属性,则用户 代理人必须解释合同的内容 元素作为脚本。如果src 具有URI值,用户代理必须 忽略元素的内容和 通过URI检索脚本

(通过使用Chrome的开发工具查看MathJax演示发现)

它以编程方式创建新的
标记,并将它们放在
标记中,就像or那样

类似于

var scr = document.createElement('script');
scr.setAttribute('src', 'path/to/script.js');
headDOMnode.appendChild(src); // 'path/to/script.js' starts to load..
执行
MathJax.Hub.Config()
时发生

Edit:head.js和require.js当然需要更多的铃声和口哨。

@Bakudan“可能是”?你确定你看过说明书了吗?上述报价中所述的标准行为。如果你不相信说明书,我想我无法进一步帮助你。
var scr = document.createElement('script');
scr.setAttribute('src', 'path/to/script.js');
headDOMnode.appendChild(src); // 'path/to/script.js' starts to load..