Quick steps to debug your module's css

Someone on the Drupal Dev list asked what to do when his custom module's CSS wasn't showing up. This is the quick checklist I sent in reply:

In order:

0. Make extra-sure your module's enabled on admin/build/modules

1. Check your drupal_add_css() call. Should look roughly like:
drupal_add_css(drupal_get_path('module', 'MYMODULE') .'/css/MYMODULE.css');

2. Make sure you're doing drupal_add_css() inside hook_init()

3. Test with css aggregation (admin/settings/performance) turned OFF on production and verify that your css appears in the head tag. If it doesn't, sanity check: make sure you're updating production code correctly (a simple comment in page.tpl.php or your main stylesheet works), check the watchdog for obvious errors.

4. Turn aggregation back on, see if css shows up now

5. If not, clear cache (admin/settings/performance)

6. Verify that you don't need to restart memcache/apache/etc, do it if needed

7. Go back to step 0 and try again

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <embed> <blockquote>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <csss>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. The supported tag styles are: <foo>, [foo].

More information about formatting options