是否可以在独立的HTML文件中"inline"或"embed"整个javascript库?



这是任何经验丰富的网络开发人员(我本人不是)的一般问题。考虑下面的代码示例中的<script>标签的html文件

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>QS Sensitivity</title>
        <script type="text/x-mathjax-config" async>MathJax.Hub.Config({menuSettings: {zoom: "Hover", zscale: "125%"}});</script>
        <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML" async></script>

可以在独立html文件中"内联"或"嵌入" MathJax库,以便可以以完整的 offline 来查看该文件,并且没有本地副本的本地副本库,不必访问CDN服务器?我尝试使用称为Inliner(npm/remy/inliner)的JS工具,该工具部分工作,但我遇到了一些问题。有人知道这样做的方法吗?

您需要做的就是将远程文件的内容放在其自己的脚本标签中:

已删除代码以简短:

<script type="text/x-mathjax-config" async>
     MathJax.Hub.Config({menuSettings: {zoom: "Hover", zscale: "125%"}});
</script>
<script>
/*
 *  /MathJax.js
 *
 *  Copyright (c) 2009-2016 The MathJax Consortium
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
    if(document.getElementById&&document.childNodes&&document.createElement){if(!
(window.MathJax&&MathJax.Hub)){if(window.MathJax){window.MathJax=
{AuthorConfig:window.MathJax}}else{window.MathJax=
{}}MathJax.isPacked=true;MathJax.version="2.7.0";MathJax.fileversion="2.7.0";
MathJax.cdnVersion="2.7.0";MathJax.cdnFileVersions={};(function(d)
{var b=window[d];if(!b){b=window[d]={}}var e=[];var c=function(f)
{var {if(f.hasOwnProperty(h))
umentMode<9;MathJax.Hub.msieHTMLCollectionBug=
(document.documentMode<9);if(document.documentMode<10&&!s.params.NoMathPlayer){try{new ActiveXObject("MathPlayer.Factory.1");j.hasMathPlayer=true}catch(m)
{}try{if(j.hasMathPlayer){var r", zscale: "125%"}});
</script>

最新更新