2

My drupal site isn't loading JS files nor CSS files located

sites/default/files/js 

OR

sites/default/files/css

even though they are there I can see them on FTP, their permissions are 664 and I can't change them they keep going back to 664. other files in sites/default/ are being loaded but not those.

Locally the site is working fine so I know it's a server issue! any suggestions?

8
  • 1
    Try a change a file permission 664 to 644 Commented Mar 31, 2014 at 9:40
  • @Mehul, I just tried, it got back to 664, I am unable to change it for some reason! Commented Mar 31, 2014 at 18:41
  • 1
    Have you clear the cache ? Commented Apr 2, 2014 at 2:50
  • 1
    what is permission of css and js folders? Commented Apr 2, 2014 at 13:16
  • 1
    Have a look at this topic : drupal.stackexchange.com/questions/20364/… Hope it will help! Commented Apr 3, 2014 at 19:04

5 Answers 5

1

Have you checked your theme to make sure the css and js files are there? The info file?

Sign up to request clarification or add additional context in comments.

1 Comment

I actually see the 404 in the firebug console, I mean the browser tried to connect but didn't get the file
1

Make sure folders (sites/default/files/js and sites/default/files/css) permission is 755 or 744
it's important to User have executable permission to this folders

Comments

1

First of all, it is not advisable to keep your JS & CSS files in sites/default folder. They should be kept in the sites/all/theme or sites/all/modules directory.

And, even then it is not necessary that they will be loaded on your website. You must specify it if you want to load these file on your site. This is how it is done:

For Theme:

add scripts[] = mytheme.js in the theme.info file to add js

add stylesheets[all][] = mytheme.css in the theme.info file to add css

For Module:

use drupal_add_js('path_to_file') to add js file

use drupal_add_css('path_to_file') to add css file

Considering that for some reason you have put the files in sites/default folder, you will need to provide the read permissions to the files. Its advisable to set them to 755.

1 Comment

Those files are there after checking compress JS and CSS in admin performance page. They are included to the browser because, I commented up earlier that: I actually see the 404 in the firebug console, I mean the browser tried to connect but didn't get the file. I will try to move them even though Drupal put them there and loads them automatically...
1

The first question is, how do you include those css & Js to your site? using a module or from a theme? In all cases, you should put them either in the module directory or in the theme directory. If you put them in the theme directory, you should add those files to your .info file of the theme. This is the best way to include CSS/JS files to a theme.

1 Comment

Those files are there after checking compress JS and CSS in admin performance page. They are included to the browser because, I commented up earlier that: I actually see the 404 in the firebug console, I mean the browser tried to connect but didn't get the file. I will try to move them even though Drupal put them there and loads them automatically...
0

For clarity's sake

  • 404 means the server could not locate the resource (file in this case).
  • If you file permissions are 664, and it's parent folders are also 664, then anyone can read the file so this seems like a non issue.

@kellyjohnson is asking if the files exist, because of what the 404 error means conceptually. He seems to understand that you are observing the 404 in your browser console. That is agreed upon. But the natural question then is do the files physically exists where you expect them to be. If you can verify that files exist then there are only a couple options left to explore.

Cases

  1. In the case of public assets (assets under the application's document root), it's likely the server's document root is not what you believe it to be; in other words the absolute path to the files for which the server is attempting to server is not the same path to the physical location of your files.

    a) Debug this issue by determining your configured document root, which will likely be the base path of the main "index.php" application entry point. From there trace your relative path to your assets. If you still believe all is correct then the remaining option would be that the web server is rewriting your requests for assets, and that is where your attention should focus.

  2. In the case of non public assets (assets outside of the document root) it's likely your application routing is not routing to the directory you are assuming it should route to.

    b) this case is arguably the easier to debug, because you will enter the application which at any point you can echo debugging code, and trace the execution to the asset provider.

Good Luck.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.