Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在html页面中包含jQuery插件而不下载插件_Jquery_Html - Fatal编程技术网

在html页面中包含jQuery插件而不下载插件

在html页面中包含jQuery插件而不下载插件,jquery,html,Jquery,Html,我想在html页面中包含一个jQuery插件,但我希望每当我办公室的人创建这个html页面时都包含这个插件,而不强迫他们下载插件。 更具体地说,我有创建html表的php脚本。这是脚本的开头(相关部分): $pre .= '<html>'; $pre .= '<head>'; $pre .= '<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"><

我想在html页面中包含一个jQuery插件,但我希望每当我办公室的人创建这个html页面时都包含这个插件,而不强迫他们下载插件。 更具体地说,我有创建html表的php脚本。这是脚本的开头(相关部分):

$pre .= '<html>';
$pre .= '<head>';
$pre .= '<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>';
$pre .= '<script type="text/javascript" src="/home/bar/Downloads/tablesorter-master/jquery.tablesorter.js"></script> ';
$pre .= '<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">';
$pre .= '</head>';
$pre .= '<body>';
$pre.='';
$pre.='';
$pre.='';
$pre.='';
$pre.='';
$pre.='';
$pre.='';

现在,考虑从本地计算机中插入插件“强>不<强”,将是一种优雅的方式。我考虑过使用cdn,但我从未尝试过处理它,所以我想知道是否有更好的解决方案,或者cdn是否是我的答案??如果是这样的话……有没有免费的方式?thx

我想您试图解决的问题是只包含一次la tablesorter脚本,这样客户端就不必下载它,也不必将它放在计算机上。 这是我的主张:

对脚本的引用不是绝对的否

'<script type="text/javascript" src="/home/bar/Download/tablesorter-master/jquery.tablesorter.js"></script> ';
”;
但是

”;
假设tablesorter master是一个目录,并且您的php文件与它位于同一个文件夹中。
因此,只有您的php服务器包含该库。

因此,基本上您正在寻找一个存储.js文件的位置?CDN就是这样做的。另一种选择是,你可以在自己的服务器中存储脚本,并提供该链接。“每当我办公室的人创建这个html时”,你能详细说明一下吗?应用程序是如何工作的?“不强迫他们下载插件”否则JS将如何执行?浏览器需要下载脚本(从cdn或您自己的服务器获取)创建此html=执行php脚本(我包括其中的一部分),对于这个问题,我认为执行php脚本生成html文件就足够了。“JS如何执行?”?这就是我问题背后的全部想法,尝试学习一种新的解决方案,而不是使用CDN。php脚本在哪里?在您的web服务器上?用户如何执行php脚本?
'<script type="text/javascript" src="tablesorter-master/jquery.tablesorter.js"></script> ';