Skip to content

Commit

Permalink
Replace regexp to plain string for optimization render HTML (#33306)
Browse files Browse the repository at this point in the history
## Bug

Line `const [renderTargetPrefix, renderTargetSuffix] = documentHTML.split(*)` with RegExp almost 80 times slower than a plain string.

Before:
![telegram-cloud-photo-size-2-5409140542421448593-y](https://user-images.githubusercontent.com/22259080/149506024-84365840-5b0f-481f-b05f-1381d839c579.jpg)


After:
![telegram-cloud-photo-size-2-5409140542421448594-y](https://user-images.githubusercontent.com/22259080/149506036-0df69ae7-e265-40da-a865-73c84496aa58.jpg)
  • Loading branch information
NOCELL authored Jan 17, 2022
1 parent 2c9c8f7 commit 8dc4670
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/next/server/render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1431,7 +1431,7 @@ export async function renderToHTML(
}

const [renderTargetPrefix, renderTargetSuffix] = documentHTML.split(
/<next-js-internal-body-render-target><\/next-js-internal-body-render-target>/
'<next-js-internal-body-render-target></next-js-internal-body-render-target>'
)

const prefix: Array<string> = []
Expand Down

0 comments on commit 8dc4670

Please sign in to comment.