tags:

views:

167

answers:

1

When I delete "Page requisites" cache, my 2 Javascript files that I use for my home page image rotator get deleted. Here is how I'm adding the javascript for those 2 files into a WYSIWYG editor with PHP code enabled:

<?
drupal_add_js('sites/default/files/js/jquery.jcarousellite.js');
drupal_add_js('sites/default/files/js/cycle.js');
?>
Some html here for the rotator......

Then I also have some JS code added to the home page only using the js Injector .

Any ideas why this is happening?

thanks

+2  A: 

You shouldn't have permanent js files located in your files folder. Either they should be in your theme or a module that uses them. The files folder is meant for uploaded files and other files that Drupal creates on the fly.

The reason to your problem is probably that Drupal has write access to the folder where you have placed the files, and it cleans out in it, since it's only used for compressions. You should think twice about which files you let drupal write to. Letting Drupal have write access to a script file you use, is an added security risk.

Generally, you don't want to let Drupal write to js or php files. This is because if a cracker would be able to get Drupal to write to those files, he would be able to more or less gain control over your entire site. This is also why the compressed js files that drupal uses has a long and random name.

So try moving those files into your theme and see if that doesn't fix it. If you want to link to them you can do

drupal_add_js(drupal_get_path('theme', 'name_of_your_theme') . 'path/to/file.js');
googletorp
Perfect. Thank you!
EricP