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

时间:2015-12-01 14:43:17

标签: 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"></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>';

现在,从本地计算机中包含tablesorter插件的优雅方式是什么。我想过使用cdn也许,但我从来没有尝试过处理它,所以我想知道是否有更好的解决方案,或者cdn是我的答案?如果是这样的话......有免费的方式吗? THX

1 个答案:

答案 0 :(得分:0)

我认为你要解决的问题是只包含la tablesorter脚本一次,以便客户端不必下载它,或者将它放在他的计算机上。  这是我的主张:

对脚本的引用并非绝对没有

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

但是

'<script type="text/javascript" src="tablesorter-master/jquery.tablesorter.js"></script> ';

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

相关问题