I'm getting "[Violation] Avoid using document.write()." in Google Dev tools. I inherited the code and am not sure how to correct or update it. It is on two lines:
function include(scriptUrl){document.write('<script src="'+scriptUrl+'"></script>');}
and
document.write('<meta name="viewport" content="width=device-width,initial-scale=1.0'+userScale+'">');
I've read the answers on this forum, but there are several "includes" of jquery files within subsequent functions, and I can't target where "scriptURL" is being populated. The final output is list of js files. Here is an example function that supplies this "scriptURL" variable:
(function($) {
var o = $('.thumb');
if (o.length > 0) {
include('js/jquery.fancybox.js');
include('js/jquery.fancybox-media.js');
$(document).ready(function() {
o.fancybox();
});
}
})(jQuery);;
where the "js/jquery.fancybox.js" and "js/jquery.fancybox-media.js" files are output as
<script src="js/jquery.fancybox.js"></script>
<script src="js/jquery.fancybox-media.js"></script>
above the body tag.
The 'meta name="viewport' function above follows this function:
var ua = navigator.userAgent.toLocaleLowerCase(),
regV = /ipod|ipad|iphone/gi,
result = ua.match(regV),
userScale = "";
if (!result) {
userScale = ",user-scalable=0"
}
Any help is appreciated.