perf($compile): only use document fragments and copy data when necessary