4.6.x core.php hook_footer($main = 0)
4.7.x core.php hook_footer($main = 0)
5.x core.php hook_footer($main = 0)
6.x core.php hook_footer($main = 0)

Insert closing HTML.

This hook enables modules to insert HTML just before the \</body\> closing tag of web pages. This is useful for adding JavaScript code to the footer and for outputting debug information. It is not possible to add JavaScript to the header at this point, and developers wishing to do so should use hook_init() instead.


$main: Whether the current page is the front page of the site.

Return value

The HTML to be inserted.

Related topics

1 function implements hook_footer()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

drupal_page_footer in includes/common.inc
Perform end-of-request tasks.
1 invocation of hook_footer()
theme_closure in includes/theme.inc
Execute hook_footer() which is run at the end of the page right before the close of the body tag.


developer/hooks/core.php, line 704
These are the hooks that are invoked by the Drupal core.


function hook_footer($main = 0) {
  if (variable_get('dev_query', 0)) {
    return '<div style="clear:both;">' . devel_query_table() . '</div>';


pieter_duijves’s picture

for Drupal 6 it seems to be possible to manipulate the header JavaScript for passing the Drupal.settings variable in hook_footer(). in other words, drupal_add_js($data = NULL, $type = 'setting') can be used in hook_footer().

valderama’s picture

For Drupal 7 you can use hook_page_alter: http://preprocess.me/drupal-hookfooter-in-drupal-7