Having a bunch of 3rd party tracking and adservers scripts that are executed by using documnet.write() and I do believe using this method is not the best practice and instead one should use the dom friendly manipulation mentioned by anakata here
Now my question is where in the page(head, foot, body etc) and when (on page load, after the page is loaded or while the page is loading) can we fire these scripts?
current script example:
<script type="text/javascript">
var p = (("https:" == document.location.protocol) ? "https://" : "http://");
document.write(unescape("%3Cscript src='" + p + "clickops.net/clickops-tracker.v1.js' type='text/javascript'%3E%3C/script%3E"));
</script>
Can we use this snippet to append external scripts as a good example?
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "path/to/your/javascript.js"; // use this for linked script
document.head.appendChild(script);
I appreciate your valuable feedback.