8000 Core: Switch `$.parseHTML` from `document.implementation` to `DOMParser` by mgol · Pull Request #5572 · jquery/jquery · GitHub
[go: up one dir, main page]

Skip to content

Conversation

mgol
Copy link
Member
@mgol mgol commented Oct 20, 2024

Summary

Using a document created via:

document.implementation.createHTMLDocument( "" )

was needed in IE 9 which doesn't support DOMParser#parseFromString for text/html. We can switch to:

( new window.DOMParser() ) .parseFromString( "", "text/html" )

now, saving some bytes.

Size comparison:

main @640d5825df5ff223560c5690f1a268681c32f9fa
   raw     gz     br Filename
   -42    -22     -3 dist/jquery.min.js
   -42    -22    -46 dist/jquery.slim.min.js
   -42    -22    -72 dist-module/jquery.module.min.js
   -42    -23    -19 dist-module/jquery.slim.module.min.js

Checklist

@mgol mgol self-assigned this Oct 20, 2024
Using a document created via:
```js
document.implementation.createHTMLDocument( "" )
```
was needed in IE 9 which doesn't support `DOMParser#parseFromString` for
`text/html`. We can switch to:
```js
( new window.DOMParser() ) .parseFromString( "", "text/html" )
```
now, saving some bytes.
@mgol mgol force-pushed the parseHTML-DOMParser branch from a881b2c to 3b6a766 Compare November 25, 2024 23:09
@mgol mgol added this to the 4.0.0 milestone Dec 10, 2024
@mgol mgol removed the Needs review label Dec 10, 2024
@mgol mgol merged commit 0e12350 into jquery:main Dec 10, 2024
17 checks passed
@mgol mgol deleted the parseHTML-DOMParser branch December 10, 2024 23:38
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Development

Successfully merging this pull request may close these issues.

3 participants

0