(1) setAttribute doesn't work in IE8 or below.
(2) you are not attaching the script to the document. You can create all
the dynamic elements you want (scripts or otherwise) but unless they are
attached to the document or something in it they will evaporate as soon as the function returns.
(3) Even if you fix #2, you need to provide for the latency period that it will take to download the script after its dynamically inserted.