Why should I remove script tags from the DOM?

709 Views Asked by At

I just discovered a framework removing the script tags from the markup after the page was finished loading. I've tried searching for a "why", but all I discover is many people searching for a way to do it without saying why.

Is this a safety precaution?

Are there other tags that should be removed after as well?


As an example, here's a previous question that I asked about it just a little while ago:

Why are <script> tags not showing up in the inspector in Firefox on the todomvc example for AngularJS but are for the source?

That's originally where I discovered this.

I got one comment there that explained why he would do it in his case.

I don't know angularjs that well to tell why they remove the script that are not templates, could be a coding guideline. I myself remove them, because jquery once had an unexpected behavior that had the result that scripts where executed each time one of their ancestors where wraped. The bug is fixed but to avoid that this happens again I remove them.

0

There are 0 best solutions below