We are facing an issue with our website where a logo provided by a third party should be loading (the logo serves as a verification link for users).
To resolve this, we have been instructed to add a short script in the header
<script type="text/javascript">
//<![CDATA[
var tlJsHost = ((window.location.protocol == "https:") ?
"https://secure.comodo.com/" : "http://www.trustlogo.com/");
document.write(unescape("%3Cscript src='" + tlJsHost +
"trustlogo/javascript/trustlogo.js'
type='text/javascript'%3E%3C/script%3E"));
//]]>
</script>
Additionally, another script needs to be included in the body:
<script language="JavaScript" type="text/javascript">
TrustLogo("https://ourfakesite.com/logo.png", "CL1", "none");
</script>
Initially, everything worked smoothly: the external script was loaded, the function executed, and the logo displayed. Perfect.
The issue arose when the remote site experienced significant slowdowns...all pages containing the logo loading scripts also slowed down due to synchronous script execution.
Ideally, I am looking for a solution that mimics an asynchronous AJAX call...loading the page first, then fetching additional content afterwards.
I have attempted various combinations of async/defer attributes and experimented with AJAX, but it seems that the document.write function causes problems after the page has fully loaded, resulting in disappearance of existing content before displaying the logo. (It appears that this is expected behavior with document.write post-page load.)
Is there a workaround for this issue? Are there alternative methods that I have overlooked?