Best practice is to keep
wp_footer() in your footer.php. Although the codex says, and I quote
Put this template tag immediately before tag in a theme
template (ex. footer.php, index.php).
it is best keeping
wp_footer() in the footer. From the PluginAPI for the
When included, the default output for this function is the admin panel
which will be shown in the top of the theme. It should be kept in the
footer for every theme because most of the plugin bind their script
files or functions to this hook.
To conclude, when creating a custom footer.php, include
wp_footer() in this custom template as well.
Just to elaborate more on your question. The closing
</body> tag is the 2nd last tag called for a page, and is situated in the footer.php. Also, most importantly, the closing
</html> tag is the last tag in the footer.php. This wraps up your site.
Have a look at the footer for the bundled theme, twentyfourteen
* The template for displaying the footer
* Contains footer content and the closing of the #main and #page div elements.
* @package WordPress
* @subpackage Twenty_Fourteen
* @since Twenty Fourteen 1.0
</div><!-- #main -->
<footer id="colophon" class="site-footer" role="contentinfo">
<?php get_sidebar( 'footer' ); ?>
<?php do_action( 'twentyfourteen_credits' ); ?>
<a href="<?php echo esc_url( __( 'http://wordpress.org/', 'twentyfourteen' ) ); ?>"><?php printf( __( 'Proudly powered by %s', 'twentyfourteen' ), 'WordPress' ); ?></a>
</div><!-- .site-info -->
</footer><!-- #colophon -->
</div><!-- #page -->
<?php wp_footer(); ?>
The last three lines of code is the most important.So it is very important to have a footer for these reasons as well, otherwise you will break the
<html> tags. Don't leave out the footer, rather copy your footer.php, rename it, customize it, and call it where needed, and remember, don't move
wp_footer() out of the footer