This question is a follow up question for this question.
If some browsers download JS files even though the user has JS disabled, would it make sense to include JS files using JS to ensure the user isn't forced to download the JS unnecessarily?
For example:
function inc(filename){
var body = document.getElementsByTagName('body').item(0);
script = document.createElement('script');
script.src = filename;
script.type = 'text/javascript';
body.appendChild(script);
}
I found the above code here.
Are there any downsides to this code? I haven't tested it yet to make sure it works properly, but it seems pretty straightforward.
I'm trying to avoid having multiple HTTP requests plus the download footprint of the code forced upon users that clearly don't want it.
Also, how would this work if the user enabled JS after initially loading the site?
Does this even matter? Is it worth being concerned over?