I have an HTML page with a couple javascript buttons that ‘replace’ the HTML/CSS.
However, when the page loads, there is an annoying delay between when the HTML/CSS loads and when the js ‘replaces’ it . (An example of what I’m talking about can be seen on the site: http://www.psd2html.com). What accounts for this delay and what is the best practice in terms of having the js load before a user experiences a delay (for example on Facebook or Youtube or any other large site with lots of js). Thank you.
To avoid the delay define your
replaceElement()function in<head>then use<script>tags inside<body>to call that function right after the element to be replaced is loaded: