2012-05-21 18 views
13

joomla- Jak usunąć niepotrzebne pliki js stronyjoomla- Jak usunąć niepotrzebne pliki js strony

Użyłem wtyczek kilka stron tak wiele plików js są zawarte we wszystkich stronach

+0

Jeśli plik javascript jest potrzebny wtyczce, możesz napotkać problemy, jeśli ją usuniesz. Czy nie byłoby lepiej usunąć samą wtyczkę? To powinno również usunąć plik javascript. – Okonomiyaki3000

Odpowiedz

23

Istnieją dwa sposoby, że jestem świadomy:

1) get instancję jeśli obiektu dokumentu i usunąć pliki js (można to zrobić w plugin):

<?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) usunąć pliki js bezpośrednio z szablonów index.php:

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

wystarczy zmodyfikować te wtyczki kodują, aby usunąć te pliki. lub odinstaluj te wtyczki, jeśli nie jest to wymagane.

-7
**An easiest way to disable mootools/ unwanted javascripts for your site in joomla cms (2.5 version)**(still loads it for your admin) 


**Step-1:** 
Using your favorite file editor, open for edit: 
libraries/joomla/document/html/renderer/head.php 

**Step-2:** check for code in head.php 

// Generate script file links 
foreach ($document->_scripts as $strSrc => $strAttr) 
{ 
// *** start *** // 
$ex_src = explode("/",$strSrc); 
$js_file_name = $ex_src[count($ex_src)-1]; 
$js_to_ignore = array("mootools-more.js","core.js"); // scripts to skip loading 
//skip loading scripts.. 
if(in_array($js_file_name,$js_to_ignore) AND substr_count($document->baseurl,"/administrator") < 1 AND $_GET['view'] != 'form'){continue;} 
// *** end *** // 


**Step-3:** 
Clear cache & refresh page. 


it works for sure. 

For detailed explanation : http://www.inmotionhosting.com/support/edu/joomla-25/302-disable-mootools-in-joomla-25 
+5

Modyfikowanie plików podstawowych nie jest zalecane – betweenbrain

5

Jeśli chcesz usunąć wszystkie skrypty Jo omla dodaje, w tym skrypcie inline, najszybszym sposobem jest taka:

$this->_script = $this->_scripts = array(); 

Dodaj gdziekolwiek w pliku szablonu powyższej sekcji <head>.

Powiązane problemy