Why do some sites (or advertisers that give clients javascript code) employ a technique of splitting the and/or
tags
The inside the Javascript string litteral is interpreted by the HTML parser as a closing tag, causing unexpected behaviour (see example on JSFiddle).
To avoid this, you can place your javascript between comments (this style of coding was common practice, back when Javascript was poorly supported among browsers). This would work (see example in JSFiddle):
');
}
// -->
...but to be honest, using document.write
is not something I would consider best practice. Why not manipulating the DOM directly?