2016-10-08 11:54:06 +03:00
|
|
|
<!doctype html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>async load by script</title>
|
|
|
|
<script type="application/javascript">
|
2016-12-05 17:41:17 +03:00
|
|
|
// inject a script using appendChild
|
|
|
|
// the script will load a pixel
|
2016-10-08 11:54:06 +03:00
|
|
|
function inject_js() {
|
2016-12-05 17:41:17 +03:00
|
|
|
var js=window.document.createElement("script");
|
2016-10-08 11:54:06 +03:00
|
|
|
js.setAttribute("async","true");
|
|
|
|
js.type="text/javascript"
|
2020-01-31 15:05:56 +03:00
|
|
|
js.src="https://gist.githack.com/gunesacar/b927d3fe69f3e7bf456da5192f74beea/raw/8d3e490b5988c633101ec45ef1443e61b1fd495e/inject_pixel.js";
|
2016-10-08 11:54:06 +03:00
|
|
|
window.document.body.appendChild(js);
|
|
|
|
}
|
|
|
|
// inject image using innerHTML
|
|
|
|
function inject_image() {
|
|
|
|
var img_div = document.getElementById("img-div-inline");
|
|
|
|
img_div.innerHTML = "<img src='shared/test_image.png' />";
|
|
|
|
}
|
|
|
|
function inject_all() {
|
|
|
|
inject_js();
|
|
|
|
inject_image();
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body onload="inject_all()">
|
|
|
|
<p> The scripts on this page inject an image, an invisible pixel and a script.</p>
|
|
|
|
<div id='pixel-div'></div>
|
|
|
|
<div id='img-div-inline'></div>
|
|
|
|
</body></html>
|