the javascript below redirects based on GEOIP :
<script type="text/javascript">
var script = document.createElement('script');
script.src = "//freegeoip.net/json/?callback=nyGeoIP";
document.getElementsByTagName('head')[0].appendChild(script);
function nyGeoIP(d) {
if (d.country_code === 'XX') {
window.location = 'http://www.domain.com';
}
}
</script>
Can someone please let me know how to amend this code so that it calls the FREEGEOIP server after dom ready (after page load).
The FreeGeoIP server often does not respond which blocks page rendering , and tools such as gtmetrix/webpagetest show loading times of 1-2 minutes when the FREEGEOIP server is not responding.