I modified the question/answer in the SO post below to remove styles, in forward order.
The question/answer removes scripts in reverse order.
It did not work. However, if I changed it back to reverse order things worked.
My guess, was that if you remove style[0]
, that style[1]
would immediately update to become style[0], in an example w/ only two styles. Hence the loop would fail.
Is this correct?
Is the style array updated near instantaneously as it is modified?
var scripts = document.getElementsByTagName("script");
for (var i=scripts.length; i--; ){
(scripts[i]).parentNode.removeChild(scripts[i]);
}