function loadFormAssemblyFormHeadAndBodyContents() {
    var headContent = "<!-- FORM: HEAD SECTION -->\n    <meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\" \/>\n    <meta name=\"referrer\" content=\"no-referrer-when-downgrade\">\n    <!-- THIS SCRIPT NEEDS TO BE LOADED FIRST BEFORE wforms.js -->\n    <script type=\"text\/javascript\" data-for=\"FA__DOMContentLoadedEventDispatch\" src=\"https:\/\/tippingpoint.tfaforms.net\/js\/FA__DOMContentLoadedEventDispatcher.js\" defer><\/script>\n                        <style>\n                    .captcha {\n                        padding-bottom: 1em !important;\n                    }\n                    .wForm .captcha .oneField {\n                        margin: 0;\n                        padding: 0;\n                    }\n                <\/style>\n                <script type=\"text\/javascript\">\n                    \/\/ initialize our variables\n                    var captchaReady = 0;\n                    var wFORMSReady = 0;\n                    var isConditionalSubmitEnabled = false;\n\n                    \/\/ when wForms is loaded call this\n                    var wformsReadyCallback = function () {\n                        \/\/ using this var to denote if wForms is loaded\n                        wFORMSReady = 1;\n                        isConditionalSubmitEnabled = document.getElementById('submit_button').hasAttribute('data-condition');\n                        \/\/ call our recaptcha function which is dependent on both\n                        \/\/ wForms and an async call to google\n                        \/\/ note the meat of this function wont fire until both\n                        \/\/ wFORMSReady = 1 and captchaReady = 1\n                        onloadCallback();\n                    }\n                    var gCaptchaReadyCallback = function() {\n                        \/\/ using this var to denote if captcha is loaded\n                        captchaReady = 1;\n                        isConditionalSubmitEnabled = document.getElementById('submit_button').hasAttribute('data-condition');\n                        \/\/ call our recaptcha function which is dependent on both\n                        \/\/ wForms and an async call to google\n                        \/\/ note the meat of this function wont fire until both\n                        \/\/ wFORMSReady = 1 and captchaReady = 1\n                        onloadCallback();\n                    };\n\n                    \/\/ add event listener to fire when wForms is fully loaded\n                    document.addEventListener(\"wFORMSLoaded\", wformsReadyCallback);\n\n                    var enableSubmitButton = function() {\n                        var submitButton = document.getElementById('submit_button');\n                        var explanation = document.getElementById('disabled-explanation');\n                        var isConditionalSubmitConditionMet = wFORMS.behaviors.condition.isConditionalSubmitConditionMet;\n                        if (\n                            submitButton != null &&\n                            (isConditionalSubmitEnabled && isConditionalSubmitConditionMet) ||\n                            !isConditionalSubmitEnabled\n                        )\n                        {\n                            submitButton.removeAttribute('disabled');\n                            if (explanation != null) {\n                                explanation.style.display = 'none';\n                            }\n                        }\n                    };\n                    var disableSubmitButton = function() {\n                        var submitButton = document.getElementById('submit_button');\n                        var explanation = document.getElementById('disabled-explanation');\n                        if (submitButton != null) {\n                            submitButton.disabled = true;\n                            if (explanation != null) {\n                                explanation.style.display = 'block';\n                            }\n                        }\n                    };\n\n                    \/\/ call this on both captcha async complete and wforms fully\n                    \/\/ initialized since we can't be sure which will complete first\n                    \/\/ and we need both done for this to function just check that they are\n                    \/\/ done to fire the functionality\n                    var onloadCallback = function () {\n                        \/\/ if our captcha is ready (async call completed)\n                        \/\/ and wFORMS is completely loaded then we are ready to add\n                        \/\/ the captcha to the page\n                        if (captchaReady && wFORMSReady) {\n                                grecaptcha.enterprise.render('g-recaptcha-render-div', {\n                                'sitekey': '6LfMg_EaAAAAAMhDNLMlgqDChzmtYHlx1yU2y7GI',\n                                'theme': 'light',\n                                'size': 'normal',\n                                'callback': 'enableSubmitButton',\n                                'expired-callback': 'disableSubmitButton'\n                            })\n                            var oldRecaptchaCheck = parseInt('1');\n                            if (oldRecaptchaCheck === -1) {\n                                var standardCaptcha = document.getElementById(\"tfa_captcha_text\");\n                                standardCaptcha = standardCaptcha.parentNode.parentNode.parentNode;\n                                standardCaptcha.parentNode.removeChild(standardCaptcha);\n                            }\n\n                            if (!wFORMS.instances['paging']) {\n                                document.getElementById(\"g-recaptcha-render-div\").parentNode.parentNode.parentNode.style.display = \"block\";\n                                \/\/document.getElementById(\"g-recaptcha-render-div\").parentNode.parentNode.parentNode.removeAttribute(\"hidden\");\n                            }\n                            document.getElementById(\"g-recaptcha-render-div\").getAttributeNode('id').value = 'tfa_captcha_text';\n\n                            var captchaError = '';\n                            if (captchaError == '1') {\n                                var errMsgText = 'The CAPTCHA was not completed successfully.';\n                                var errMsgDiv = document.createElement('div');\n                                errMsgDiv.id = \"tfa_captcha_text-E\";\n                                errMsgDiv.className = \"err errMsg\";\n                                errMsgDiv.innerText = errMsgText;\n                                var loc = document.querySelector('.g-captcha-error');\n                                loc.insertBefore(errMsgDiv, loc.childNodes[0]);\n\n                                \/* See wFORMS.behaviors.paging.applyTo for origin of this code *\/\n                                if (wFORMS.instances['paging']) {\n                                    var b = wFORMS.instances['paging'][0];\n                                    var pp = base2.DOM.Element.querySelector(document, wFORMS.behaviors.paging.CAPTCHA_ERROR);\n                                    if (pp) {\n                                        var lastPage = 1;\n                                        for (var i = 1; i < 100; i++) {\n                                            if (b.behavior.isLastPageIndex(i)) {\n                                                lastPage = i;\n                                                break;\n                                            }\n                                        }\n                                        b.jumpTo(lastPage);\n                                    }\n                                }\n                            }\n                        }\n                    }\n                <\/script>\n                                    <script src='https:\/\/www.google.com\/recaptcha\/enterprise.js?onload=gCaptchaReadyCallback&render=explicit&hl=en_US' async\n                        defer><\/script>\n                <script type=\"text\/javascript\">\n                    document.addEventListener(\"DOMContentLoaded\", function() {\n                        var warning = document.getElementById(\"javascript-warning\");\n                        if (warning != null) {\n                            warning.parentNode.removeChild(warning);\n                        }\n                        var oldRecaptchaCheck = parseInt('1');\n                        if (oldRecaptchaCheck !== -1) {\n                            var explanation = document.getElementById('disabled-explanation');\n                            var submitButton = document.getElementById('submit_button');\n                            if (submitButton != null) {\n                                submitButton.disabled = true;\n                                if (explanation != null) {\n                                    explanation.style.display = 'block';\n                                }\n                            }\n                        }\n                    });\n                <\/script>\n                <script type=\"text\/javascript\">\n        document.addEventListener(\"FA__DOMContentLoaded\", function(){\n            const FORM_TIME_START = Math.floor((new Date).getTime()\/1000);\n            let formElement = document.getElementById(\"tfa_0\");\n            if (null === formElement) {\n                formElement = document.getElementById(\"0\");\n            }\n            let appendJsTimerElement = function(){\n                let formTimeDiff = Math.floor((new Date).getTime()\/1000) - FORM_TIME_START;\n                let cumulatedTimeElement = document.getElementById(\"tfa_dbCumulatedTime\");\n                if (null !== cumulatedTimeElement) {\n                    let cumulatedTime = parseInt(cumulatedTimeElement.value);\n                    if (null !== cumulatedTime && cumulatedTime > 0) {\n                        formTimeDiff += cumulatedTime;\n                    }\n                }\n                let jsTimeInput = document.createElement(\"input\");\n                jsTimeInput.setAttribute(\"type\", \"hidden\");\n                jsTimeInput.setAttribute(\"value\", formTimeDiff.toString());\n                jsTimeInput.setAttribute(\"name\", \"tfa_dbElapsedJsTime\");\n                jsTimeInput.setAttribute(\"id\", \"tfa_dbElapsedJsTime\");\n                jsTimeInput.setAttribute(\"autocomplete\", \"off\");\n                if (null !== formElement) {\n                    formElement.appendChild(jsTimeInput);\n                }\n            };\n            if (null !== formElement) {\n                if(formElement.addEventListener){\n                    formElement.addEventListener('submit', appendJsTimerElement, false);\n                } else if(formElement.attachEvent){\n                    formElement.attachEvent('onsubmit', appendJsTimerElement);\n                }\n            }\n        });\n    <\/script>\n\n    <link href=\"https:\/\/tippingpoint.tfaforms.net\/dist\/form-builder\/5.0.0\/wforms-layout.css?v=227395864bced79ef4dc9670793427c32079af8b\" rel=\"stylesheet\" type=\"text\/css\" \/>\n\n    <link href=\"https:\/\/tippingpoint.tfaforms.net\/uploads\/themes\/theme-68.css\" rel=\"stylesheet\" type=\"text\/css\" \/>\n    <link href=\"https:\/\/tippingpoint.tfaforms.net\/dist\/form-builder\/5.0.0\/wforms-jsonly.css?v=227395864bced79ef4dc9670793427c32079af8b\" rel=\"alternate stylesheet\" title=\"This stylesheet activated by javascript\" type=\"text\/css\" \/>\n    <script type=\"text\/javascript\" src=\"https:\/\/tippingpoint.tfaforms.net\/wForms\/3.11\/js\/wforms.js?v=227395864bced79ef4dc9670793427c32079af8b\"><\/script>\n    <script type=\"text\/javascript\">\n        wFORMS.behaviors.prefill.skip = false;\n    <\/script>\n        <script type=\"text\/javascript\" src=\"https:\/\/tippingpoint.tfaforms.net\/wForms\/3.11\/js\/localization-en_US.js?v=227395864bced79ef4dc9670793427c32079af8b\"><\/script>\n\n";
    var bodyContent = "<!-- FORM: BODY SECTION -->\n<div class=\"wFormContainer\" >\n    <div class=\"wFormHeader\"><\/div>\n    <style type=\"text\/css\">\n                #tfa_1435833140206,\n                *[id^=\"tfa_1435833140206[\"] {\n                    width: 195px !important;\n                }\n                #tfa_1435833140206-D,\n                *[id^=\"tfa_1435833140206[\"][class~=\"field-container-D\"] {\n                    width: auto !important;\n                }\n            <\/style><div class=\"\"><div class=\"wForm\" id=\"5003400-WRPR\" data-language=\"en_US\" dir=\"ltr\">\n<div class=\"codesection\" id=\"code-5003400\"><\/div>\n<form method=\"post\" action=\"https:\/\/tippingpoint.tfaforms.net\/api_v2\/workflow\/processor\" class=\"hintsBelow labelsAbove\" id=\"5003400\" role=\"form\">\n<div id=\"tfa_1435833140211\" class=\"section inline group\">\n<div class=\"oneField field-container-D  labelsRemoved  \" id=\"tfa_2-D\"><div class=\"inputWrapper\"><input aria-required=\"true\" type=\"text\" id=\"tfa_2\" name=\"tfa_2\" value=\"\" placeholder=\"First Name\" title=\"First Name\" class=\"required\"><\/div><\/div>\n<div class=\"oneField field-container-D  labelsRemoved  \" id=\"tfa_3-D\"><div class=\"inputWrapper\"><input aria-required=\"true\" type=\"text\" id=\"tfa_3\" name=\"tfa_3\" value=\"\" placeholder=\"Last Name\" title=\"Last Name\" class=\"required\"><\/div><\/div>\n<\/div>\n<div class=\"oneField field-container-D  labelsRemoved  \" id=\"tfa_4-D\"><div class=\"inputWrapper\"><input aria-required=\"true\" type=\"text\" id=\"tfa_4\" name=\"tfa_4\" value=\"\" placeholder=\"Email\" title=\"Email\" class=\"validate-email required\"><\/div><\/div>\n<div id=\"tfa_1435833140205\" class=\"section group wf-acl-hidden\">\n<input type=\"hidden\" id=\"tfa_1435833140206\" name=\"tfa_1435833140206\" value=\"UA-6029045-2\" class=\"calc-GOOGLEACCOUNTID\"><div class=\"htmlSection\" id=\"tfa_1435833140207\"><div class=\"htmlContent\" id=\"tfa_1435833140207-HTML\"><\/div><\/div>\n<\/div>\n<div id=\"tfa_1435833140208\" class=\"section group wf-acl-hidden\"><div class=\"htmlSection\" id=\"tfa_1435833140209\"><div class=\"htmlContent\" id=\"tfa_1435833140209-HTML\"><\/div><\/div><\/div>\n<div id=\"tfa_1435833140213\" class=\"section inline group\"><input type=\"hidden\" id=\"tfa_1435833140210\" name=\"tfa_1435833140210\" value=\"\" class=\"\"><\/div>\n<div class=\"actions\" id=\"5003400-A\" data-contentid=\"submit_button\">\n<div id=\"google-captcha\" style=\"display: none\">\n<br><div class=\"captcha\">\n<div class=\"oneField\">\n<div class=\"g-recaptcha\" id=\"g-recaptcha-render-div\"><\/div>\n<div class=\"g-captcha-error\"><\/div>\n<br>\n<\/div>\n<div class=\"captchaHelp\">reCAPTCHA helps prevent automated form spam.<br>\n<\/div>\n<div id=\"disabled-explanation\" class=\"captchaHelp\" style=\"display: none\">The submit button will be disabled until you complete the CAPTCHA.<\/div>\n<\/div>\n<\/div>\n<input type=\"submit\" data-label=\"STAY INFORMED\" class=\"primaryAction\" id=\"submit_button\" value=\"STAY INFORMED\">\n<\/div>\n<div style=\"clear:both\"><\/div>\n<input type=\"hidden\" value=\"5003400\" name=\"tfa_dbFormId\" id=\"tfa_dbFormId\"><input type=\"hidden\" value=\"\" name=\"tfa_dbResponseId\" id=\"tfa_dbResponseId\"><input type=\"hidden\" value=\"063aaadc20bd0f5357bf3e7c1b816e44\" name=\"tfa_dbControl\" id=\"tfa_dbControl\"><input type=\"hidden\" value=\"\" name=\"tfa_dbWorkflowSessionUuid\" id=\"tfa_dbWorkflowSessionUuid\"><input type=\"hidden\" value=\"\" name=\"tfa_noOverWriteFields\" id=\"tfa_noOverWriteFields\"><input type=\"hidden\" value=\"7\" name=\"tfa_dbVersionId\" id=\"tfa_dbVersionId\"><input type=\"hidden\" value=\"\" name=\"tfa_switchedoff\" id=\"tfa_switchedoff\">\n<\/form>\n<\/div><\/div><div class=\"wFormFooter\"><p class=\"supportInfo\"><br><\/p><\/div>\n  <p class=\"supportInfo\" >\n      <\/p>\n <\/div>\n\n<script\n    id=\"open-telemetry-script\"\n    type=\"text\/javascript\"\n    src=\"https:\/\/tippingpoint.tfaforms.net\/dist\/open-telemetry\/open-telemetry.e3e59835d0ec08f714f1.js\"\n    data-customer-id=\"3942\"\n    data-exporter-url=\"https:\/\/us-east-1-otel.formassembly.com\/v1\/traces\"\n    data-exporter-console=\"0\"\n><\/script>\n<script src=\"https:\/\/tippingpoint.tfaforms.net\/api_v2\/sst\/quick-publish\"><\/script>";
    var elementID = null;
    var quickPublishScript = document.querySelector('script[data-qp-target-id]');
    if (quickPublishScript) {
        elementID = quickPublishScript.getAttribute('data-qp-target-id');
    }

    // append head content
    var head = document.createElement('head');
    head.innerHTML = headContent;
    var headElements = head.children;

    // filter out the script tags with src from headElements, then recursively apply each script
    var headElementsArray = Array.from(headElements);
    var otherHeadElements = headElementsArray.filter(function (el) {
        return el.nodeName !== 'SCRIPT'
    });
    var headScriptElements = headElementsArray.filter(function (el) {
        return el.nodeName === 'SCRIPT'
    });
    loadOtherHeadElements(otherHeadElements);
    loadHeadScriptElements(headScriptElements);

    // append body content
    var body = document.createElement('body');
    body.innerHTML = bodyContent;
    var bodyElements = body.children;
    var bodyWrapperDiv = document.createElement('div');
    bodyWrapperDiv.id = "FA__QP__BODYWRAPPERDIV";
    Array.from(bodyElements).forEach(function(el) {
        if (!elementID) {
            bodyWrapperDiv.appendChild(el);
            document.body.appendChild(bodyWrapperDiv);
        } else {
            var element = document.getElementById(elementID);
            if (!element) { // insert form at the end of the page
                bodyWrapperDiv.appendChild(el);
                document.body.appendChild(bodyWrapperDiv);
            } else { // insert within element
                bodyWrapperDiv.appendChild(el);
                element.appendChild(bodyWrapperDiv);
            }
        }
    });

    document.addEventListener('FA__DOMContentLoaded', function () {
        var bodyWrapperDivFromDocument = document.getElementById("FA__QP__BODYWRAPPERDIV");
        var scriptTags = bodyWrapperDivFromDocument.querySelectorAll('script');
        Array.from(scriptTags).forEach(function (scriptTag) {
            var script = document.createElement('script');
            if (scriptTag.hasAttribute('src')) {
                script.src = scriptTag.src;
            } else {
                script.innerHTML = scriptTag.innerHTML;
            }
            // copy over other attributes of the script
            Array.from(scriptTag.attributes).forEach(function (attr) {
                if (attr.name !== 'src') {
                    script.setAttribute(attr.name, attr.value);
                }
            });
            scriptTag.replaceWith(script);
        });
    })
}

/**
 * Load other <head> elements like <meta> and <link> etc
 *
 * @param  otherHeadElements
 */
function loadOtherHeadElements(otherHeadElements) {
    var element = otherHeadElements.shift();
    document.head.appendChild(element);
    if (otherHeadElements.length) {
        loadOtherHeadElements(otherHeadElements);
    }
}

/**
* Dispatch QuickPublishDone event
*/
function dispatchQuickPublishDone() {
    document.dispatchEvent(new Event('FA__DOMContentLoaded'));
}

/**
 * Sequentially load all <head> script elements.
 *
 * @param  headScriptElements
 */
function loadHeadScriptElements(headScriptElements) {
    var faScript = headScriptElements.shift();
    var newScript = document.createElement('script');

    if (faScript.innerHTML) {
        newScript.innerHTML = faScript.innerHTML;
        document.head.appendChild(newScript);

        if (! headScriptElements.length) {
            dispatchQuickPublishDone();
            return;
        }

        return loadHeadScriptElements(headScriptElements);
    }

    document.head.appendChild(newScript);
    newScript.onload = function () {
        if (headScriptElements.length) {
            return loadHeadScriptElements(headScriptElements);
        } else {
            dispatchQuickPublishDone();
        }
    };

    Array.from(faScript.attributes).forEach(function (attr) {
        if (attr.name !== 'src') {
            newScript.setAttributeNode(attr.cloneNode(true));
        }
    });
    newScript.src = faScript.src;
}

window.addEventListener('DOMContentLoaded', loadFormAssemblyFormHeadAndBodyContents);