Add HTML Before the Closing Body Tag

Taylor Sloane Updated by Taylor Sloane

Customizing your docs with JavaScript snippets and CSS is an awesome way to make them stand out.

Most of the time you'll find dropping your custom code into Settings > Code > CSS or Javascript works super well by adding code into the <head> portion of your knowledge base. But there might be the odd occasion where you'll wanna add a snippet somewhere else. Sometimes scripts need to be added before the closing </body> tag.

For this you'll wanna use the example below replacing Your Code with your custom code and saving the entire snippet into Settings > Code > Javascript šŸ™ƒ

 var someHTML = 'Your Code'; // string of HTML here
 ready(function() {
   document.body.insertAdjacentHTML('afterend', someHTML);

 function ready(fn) {
   if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading"){
   } else {
     document.addEventListener('DOMContentLoaded', fn);

What did you think of this doc?

How to Add Extra Spacing

Customizing Feedback Icons

Get in touch

This site is protected by hCaptcha and its Privacy Policy and Terms of Service apply.