'A Fix For A Flash Of Unstyled Content That Cancels Out Javascrpit

Below is the javascript that I'm using on my website, part of which is used to get rid of a flash of unstyled content when loading a web page. Part of the checkboxes used to get the menu bar to work flash when loading a web page and the javascript that I implemented works well. However, for whatever reason, that particular javascript cancels out the other javascript I have set in place and the page no longer works as it should.

Does anyone know of a way to get rid of the flash of unstyled content on my website without it affecting any of my other javascript?

<script type="text/javascript">
 document.getElementById('frmSearch').onsubmit = function() {
 window.location = 'http://www.google.com/search?q=site:morikoboshi.com' + document.getElementById('txtSearch').value;
        return false;
    }
    
 document.getElementById('cp_toggle03').onchange = function() {
 if (document.getElementById('cp_toggle03').checked) {
 document.body.style.overflow = "hidden";
  } else {
 document.body.style.overflow = "";
  }
} 
 
if(!!window.performance && window.performance.navigation.type == 2)
{
    window.location.reload();
}
    
div.hidden
{
   display: none
}
    
$('html').addClass('flash');
$(document).ready(function() {
     /* Do all your stuff */

     /* When done show the wrapper with the content styled */
     $(wrapper).show();
});
    
</script>

<style>

.flash #wrapper {
     display: none;
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source