Loading Widget after page loads

Google’s new update is strict with measuring mobile devices, I will need to cancel this product unless I can disable it for mobile devices, I tried with document.write, but this is not advised, is there a better method to only load this tool for the desktop?