How to hardcode header and footer in WP?

You can always edit header.php and footer.php manually and entering HTML there, just be sure to call appropriate DIVI functions like

    elegant_description();
    elegant_keywords();
    elegant_canonical();
    do_action( 'et_head_meta' );

etc., and WordPress wp_head(); and others. Be warned that DIVI does a lot of tweaking and you must call necessary functions and find which are not necessary, so such optimization would not be an easy thing. WordPress’s default header.php is much simpler than DIVI’s.
In the end, you might not feel much of optimization, since all DIVI functions must load for the middle (content) part of the page.
I think it would be better concentrating on caching and optimizations with plugins like WP Super Cache, Phastpress or recent WP Meteor.
Best of luck!