Render pipeline: Javascript -> Style -> Layout -> Paint -> Composite
Javascript can cause the entire render pipeline to trigger continuously. the trick is knowing what kind of changes trigger what steps in the render pipeline and trying to trigger as few as possible.
Paint is the most expensive operation, layout is the second most expensive