I am using javascript for some of the html pages. Where should I store the javascript files in my drupal folder.
1 Answer
If it's a theme, and if you are defining scripts in .info file, keep the .js files in scripts folder of your theme folder (e.g sites/all/themes/mytheme/scripts). You don not have to define the whole path. Just enter the relative path to the .info file (scripts/myscript.js) and it will get included in the entire site.
if you are using drupal_add_js, in a custom module, the common practice is to keep the file in module's folder. Set it as drupal_get_path.
Although it's not recommended, if you are hardcoding the script in html.tpl.php or page.tpl.php folder, I'd place the js file in theme folder and use a drupal_get_path to get the actual path.
-
its not a theme. only for four html pages i am using the js. I have uploaded using upload field button in the site. But they its getting automatically renamed to js.txt file. Where should i keep them . Jul 26, 2012 at 3:11
-
1You will need to upload it using FTP. In most fields, you cannot upload executable files. even strict, you can upload only few allowed file types.– AKSJul 26, 2012 at 3:21