How To Avoid MGID Ads Overload Blogs - MGID is an
advertising network that can also be a source of income for bloggers as
publishers as well as Adsense.
And the good news, this MGID ad can be juxtaposed with Adsense ads. MGID ads are native ads such as Adsense matched content ad units and already support Indonesian.
Just as in histats
, MGID ads also disrupt or increase blog loading even though the JS is
asynchronous. But don't worry, after I tried it turns out that MGID ads can
also be tricked with defer like histats so it doesn't interfere with blog
loading.
For that, for those of you who are MGID publishers, I will now give you tricks on how to install MGID ad code so that it doesn't burden blog loading, if you really care about blog loading speed.
Usually MGID ad code like the following as an example.
<!-- Composite Start -->
<div id="M517355ScriptRootC778521">
<div id="M517355PreloadC778521"> Loading...
</div>
</div>
<script>
(function () {var script = document.createElement ('script'); script.src = "//jsc.mgid.com/b/l/bloggue.web.id.778521.js?t=" + ((( d = new Date ())? '' + d.getUTCFullYear () + d.getUTCMonth () + d.getUTCDate () + d.getUTCHours (): ''); script.async = true; document.body.appendChild (script);}) ();
</script>
<! - Composite End ->
Then change the MGID ad code to the following example.
<div id="M517355ScriptRootC778521">
<div id="M517355PreloadC778521">
Loading... </div>
</div>
<script>
//<![CDATA[
function downloadJSAtOnload(){var d=document.createElement("script");d.src="URL HOSTING code-mgid.js SAVE HERE", document.body.appendChild (d)} window.addEventListener? window.addEventListener (" load ", downloadJSAtOnload,! 1): window.attachEvent? window.attachEvent (" onload ", downloadJSAtOnload): window.onload = downloadJSAtOnload,! 1): window.attachEvent? window.attachEvent (" onload ", downloadJSAtOnload): window.onload = downloadJSAtOnload;
//]]>
</script>
<link as='script' href='URL HOSTING code-mgid.js SAVE HERE 'rel =' preload '/>
Do the same for other ad units if you place more than 1 MGID ad unit. Make sure the names of the js hosted on Github are different from each other, for example the mgid2.js code for the second ad and so on.
Or if you want this MGID ad to really not interfere with loading the blog, then we can use code like the Adsense lazyload trick. Please change the MGID ad code to the following example.
<div id='M517355ScriptRootC778521'>
<div id='M517355PreloadC778521'>
Loading... </div>
</div>
<script>
//<![CDATA[
var lazymgid = false;
window.addEventListener ("scroll", function () {
if ((document.documentElement.scrollTop! = 0 && lazymgid === false) || (document.body.scrollTop! = 0 && lazymgid === false)) {
(function () {var ad = document.createElement ('script'); ad.type = 'text / javascript'; ad.async = true; ad.src = ' URL HOSTING code-mgid.js SAVE HERE '; var sc = document.getElementsByTagName ('script') [0]; sc.parentNode.insertBefore (ad, sc); }) ();
lazymgid = true;
}
}, true);
//]]>
</script>
For the second and subsequent ad units if you place more than 1 MGID ad unit. Make sure the names of the js hosted on Github are different from each other, for example the mgid2.js code for the second ad and so on. Also make sure the code lazymgid as I lazymgid 2 above are distinguished, for example being lazymgid 2 lazymgid 2 , and so on like this example
<div id='M517355ScriptRootC778535'>
<div id='M517355PreloadC778535'>
Loading... </div>
</div>
<script>
//<![CDATA[
var lazymgid2 = false;
window.addEventListener ("scroll", function () {
if ((document.documentElement.scrollTop! = 0 && lazymgid2 === false) || (document.body.scrollTop! = 0 && lazymgid2 === false)) {
(function () {var ad = document.createElement ('script'); ad.type = 'text / javascript'; ad.async = true; ad.src = 'URL HOSTING code-mgid.js SAVE HERE'; var sc = document.getElementsByTagName ('script') [0]; sc.parentNode.insertBefore (ad, sc); }) ();
lazymgid2 = true;
}
}, true);
//]]>
</script>
<!-- Composite Start -->
<div id="M517355ScriptRootC778521">
<div id="M517355PreloadC778521"> Loading...
</div>
</div>
<script>
(function () {var script = document.createElement ('script'); script.src = "//jsc.mgid.com/b/l/bloggue.web.id.778521.js?t=" + ((( d = new Date ())? '' + d.getUTCFullYear () + d.getUTCMonth () + d.getUTCDate () + d.getUTCHours (): ''); script.async = true; document.body.appendChild (script);}) ();
</script>
<! - Composite End ->
<div id="M517355ScriptRootC778521">
<div id="M517355PreloadC778521">
Loading... </div>
</div>
<script>
//<![CDATA[
var lazymgid = false;
window.addEventListener ("scroll", function () {
if ((document.documentElement.scrollTop! = 0 && lazymgid === false) || (document.body.scrollTop! = 0 && lazymgid === false)) {
(function () {var script = document.createElement ('script'); script.src = "//jsc.mgid.com/b/l/bloggue.web.id.778521.js?t=" + ((( d = new Date ())? '' + d.getUTCFullYear () + d.getUTCMonth () + d.getUTCDate () + d.getUTCHours (): ''); script.async = true; document.body.appendChild (script);}) ();
lazymgid = true;
}
}, true);
//]]>
</script>
Good luck and hopefully useful.