Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

From where does the $scripts variable in drupal gets generated? I am getting an unwanted code generated in the html code like this

 <script type="text/javascript" src="/js/js_01770598d5388f7cbcfe786a6df4ef2a.js"></script>

I want to remove that code, for that I need to know the details about $scripts varialble used in tpl file

share|improve this question
imho you need to be certain that the included js is actually unwanted before deciding to remove it, it might be any of the contributed modules that your site uses and could paralyze some functionality. If you are certain that the script is useless you could check this and this to aid your cause. – optimusprime619 Jan 10 at 7:18
no, it is a malware – user7282 Jan 10 at 7:22
It it actually in the rendered output when you do a view source, or is it being dynamically added? – MPD Jan 10 at 15:21

1 Answer

up vote 2 down vote accepted

You should start at template_preprocess_node() where the $scripts variable is initialised:

$variables['scripts'] = drupal_get_js();

Then have a look at drupal_get_js() and follow the functions from there to find out how that mechanism works.

Then have a look at any implementations of hook_page_alter() throughout your site, where the $vars['scripts'] variable might be being manipulated.

Even though that technically answers your question, I'd be surprised if you find what you're looking for there. I've never heard of any malware that specifically targets Drupal (which is what this would be if it's manipulating the $scripts variable).

I'd check the rest of your page source to see if there's some JS being injected somewhere which is adding that <script> tag to the <head> dynamically, just in case.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.