4 ms·
document.write('<script src="https://example.com/script.js"></script>'); Since when is this valid? Last I recall, you had to break up the `</script>` end tag i
by moron4hire 10y ago
document.write('<script src="https://example.com/script.js"></script>');
Since when is this valid? Last I recall, you had to break up the `</script>` end tag into two strings.
I think a better solution to this problem would be to remove `document.write` completely. It's useless. In all cases, you're better off using something else.
- kinlan 10y agoYou can just do document.write('<script src="https://example.com/script.js"><\/script>'); https://example.com/script.js"><\/script>'); and it works
- kinlan 10y agore: removing document.write completely is a hard balance, soooo much of the web still uses it especially for 1st party script loading that it would be a more impactful issue. I do believe the consensus across all browser vendors is that we should remove it, it's just incredibly hard to do and smaller incremental steps is a better solution that keeps users happy. Personally I worry about complete document.write removal that it would ideally need to be done by all browsers at the same time because for the first browser to do it will get the majority of the user and developer pain :\
- bzbarsky 10y ago> Last I recall, you had to break up the `</script>` end tag into two strings. Only if you're an inline script. If your document.write() call is in an external script, you don't need to do anything like that.