I have code and looking for best practice to load script inside the code.
This is how I manually included before - <script src='//test.test/adition/?'></script>
If the condition is true, I need to load <script src='//test.test/adition/?'></script>
in script below.
I have found out that document.write()
is not best practice, any advices?
<script type="text/javascript">
var isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
var element = document.getElementById('text');
if (isMobile) {
} else {
console.log('error');
}
</script>