use DocumentFragment when buildin folds to speedup things.

refs https://github.com/travis-ci/travis-ci/issues/1340

wasn't able to profile it on my pc though I would love to profile it again in case you would get this up on a staging environment somewhere.