Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- AddEventHandler("main", "OnEndBufferContent", "deleteJs");
- function deleteJs(&$content) {
- global $USER, $APPLICATION;
- if((is_object($USER) && $USER->IsAuthorized()) || strpos($APPLICATION->GetCurDir(), "/bitrix/")!==false) return;
- if($APPLICATION->GetProperty("save_kernel") == "Y") return;
- if ($APPLICATION->GetCurPage(true) == SITE_DIR."index.php"){
- //css
- if(preg_match_all('#<link.+?href=".+?kernel_main\/kernel_main\.css\?\d+"[^>]+>|<link.+?href=".+?tml\/page_[^>]+>#i',$content,$hSc)){
- if(!empty($hSc[0])){
- $scriptH=implode('',$hSc[0]);//все скрипты
- $content=preg_replace('#\s*(<link.+?href=".+?kernel_main\/kernel_main\.css\?\d+"[^>]+>|<link.+?href=".+?tml\/page_[^>]+>)\s*#i','',$content);
- $content=strtr($content,array('</body>'=>$scriptH.'</body>'));
- }
- }
- if(preg_match_all('#<script(?:.|\n|\r)+?<\/script>#i',$content,$hSc)){
- if(!empty($hSc[0])){
- $scriptH=implode('',$hSc[0]);//все скрипты
- $content=preg_replace('#\s*<script(?:.|\n|\r)+?<\/script>\s*#i','',$content);
- $content = preg_replace("/<!--(.*?)-->/s", "", $content);
- $content = preg_replace("/[\x0d\x0a]+/", " ", $content);
- $content = preg_replace("/>\s{4,}</", "> <", $content);
- $content = preg_replace('/(["\'])\s+\/>/', '\1/>', $content);
- $content=strtr($content,array('</body>'=>$scriptH.'</body>'));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement