加入收藏 | 设为首页 | 会员中心 | 我要投稿 北几岛 (https://www.beijidao.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

php – joomla-如何从页面中删除不需要的js文件

发布时间:2021-07-06 05:25:54 所属栏目:大数据 来源: https://www.jb51.cc
导读:joomla-如何从页面中删除不需要的js文件 我在插件中使用了一些页面,因此所有页面都包含了很多js文件 解决方法: 我知道有两种方法: 1)获取一个实例,如果文档对象并删除js文件(你可以在插件中执行): ?PHP //get the array containing all the script declara

joomla-如何从页面中删除不需要的js文件

我在插件中使用了一些页面,因此所有页面都包含了很多js文件

解决方法:

我知道有两种方法:

1)获取一个实例,如果文档对象并删除js文件(你可以在插件中执行):

<?PHP 
         //get the array containing all the script declarations
         $document = JFactory::getDocument(); 
         $headData = $document->getHeadData();
         $scripts = $headData['scripts'];

         //remove your script, i.e. mootools
         unset($scripts['/media/system/js/mootools-core.js']);
         unset($scripts['/media/system/js/mootools-more.js']);
         $headData['scripts'] = $scripts;
         $document->setHeadData($headData);
?>

2)直接从模板index.PHP中删除js文件:

<?PHP unset($this->_scripts['/media/system/js/mootools-core.js']); ?>

(编辑:北几岛)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读