Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

amp-bind: Improve init performance #6910

Closed
2 tasks done
dreamofabear opened this issue Jan 5, 2017 · 1 comment
Closed
2 tasks done

amp-bind: Improve init performance #6910

dreamofabear opened this issue Jan 5, 2017 · 1 comment

Comments

@dreamofabear
Copy link

dreamofabear commented Jan 5, 2017

Related to #6199.

Several slow tasks are necessary during initialization. We should speed it up where possible and chunk/amortize across multiple frames otherwise:

  • DOM scan for bindings
  • Expression parsing and AST generation
@dreamofabear dreamofabear self-assigned this Jan 5, 2017
@dreamofabear
Copy link
Author

Re: DOM scan for bindings

Did some profiling and it looks like using an attribute selector with querySelectorAll is faster by roughly the proportion of bound elements to all elements.

<p bindable [attr]="expr"></p>

const boundElements = document.body.querySelectorAll('[bindable]');

However, this is less user friendly and still takes several ms for documents with thousands of elements/attributes, which may not fit in a single frame's budget.

For both cases, the majority (> 90%) of the time is spent iterating over elements and attributes. So as a first step, I'll chunk this part and set a budget of X ms for a single frame.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants