9

Why does angularjs cause multiple comments in between render data? Inspecting DOM childNodes causes extra nodes which takes up memory. Is there a way to remove them?

enter image description here

1
  • This is annoying to me as I find the need to do this angular.element(document.getElementById('modal')).append($compile(templates[type])(scope)); then try and remove the stuff that got added except that its no longer so clean and easy. I am so annoyed that I have to revert to javascript directly to manipulate the dom for dynamic templates, it is wrong keeps feeling wrong but it seems there is no other way. Commented Jun 9, 2015 at 8:05

3 Answers 3

10

Angular needs these comments to operate with some directives. Removing those comments breaks Angular and it is not allowed to do so currently.

It is also explained in this Github issue.

Sign up to request clarification or add additional context in comments.

Comments

1

Angular uses the comments do figure out where the last element was placed in relation. It's here in the source code https://github.com/angular/angular.js/commit/9efa46ae640cde17487c341daa9a75c0bd79da02

The comments are written client-side so there's no impact on transfer, and if your application is that memory conservative, Angular is probably the wrong language to use in the first place.

Comments

1

I find these comments annoying too. You can turn off the content of them though. Just set debugInfoEnabled to false in the config:

$compileProvider.debugInfoEnabled(false);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.