gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 05:31:05 26 4
gpt4 key购买 nike

对于任何经验丰富的网络开发人员来说,这是一个普遍的问题(我自己不是)..考虑<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>

是否可以将 MathJax 库“内联”或“嵌入”到独立的 HTML 文件中,以便可以离线完整地查看该文件并且无需本地副本图书馆并且无需访问 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>

关于javascript - 是否可以在独立的 HTML 文件中使用 "inline"或 "embed"整个 javascript 库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40940347/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com