# How to find which extension is adding a specific <script> to <head>

I'm having some extension adding in a script element to the head with a broken URL that keeps on 504'ing. This is occurring on a test server where I don't have full FTP permissions so editing files under app/etc/modules is out of the question. I've tried going through each extension under configuration > advanced > advanced, but still am not able to find the culprit. The script URL is just "domain.com/skin/frontend/[theme]/enterprise" as shown in this screen cap:

If I go under configuration > general > design > themes and set 'Default' to blank (currently set to enterprise), the script link url changes to "domain.com/skin/frontend/[theme-name]/default".

I've tried to grep in the layout directory for 'addJS' and 'addItem', but couldn't find anything helpful..

• Have you tried running this command (on linux): fgrep -R "prolighting" /path/to/magento – espradley Oct 2 '17 at 16:43
• @espradley I originally used grep -rn "SEARCHTERM", but I ran your fgrep against 'prolighting', 'enterprise', 'addJs', and 'addItem', but no luck yet. – T_K Oct 2 '17 at 17:38
• Yea, I just realized the "prolighting" is probably the name of your theme. So that's not going to find it. What I've done in the past in these situations is find the addJS code in the code base and then either use xdebug or log write to figure out what's being sent. – espradley Oct 2 '17 at 17:43
• @espradley Ok, so I'm at least on the right track with 'addJs' under the code base. Unfortunately, I don't have access to install xdebug so that's ruled out. How would I use log write instead? Do you have a link to a page that explains the process by chance? – T_K Oct 2 '17 at 18:06

I'm not sure if you can modify files, but look at the app/code/core/Mage/Core/Model/Layout/Update.php method getFileLayoutUpdatesXml(). It reads all layout updates for the current theme. Find line $fileStr = file_get_contents($filename);

$fileStr contains content of every loaded layout file, $filename — path to the file.

So something like

$fileStr = file_get_contents($filename);
if (strpos($fileStr, 'myfile') !== false) { file_put_contents('files.txt',$filename.PHP_EOL, FILE_APPEND);
}


can store into file.txt paths to files that mention your string.

But JS/CSS files can be added via blocks, look at the Mage_Page_Block_Html_Head::addItem() for more information