When I run JavaScript code on a web page, it causes freezing.
Specifically, if the retrieved characters contain special characters, the freeze occurs during JSON.stringify(). However, if I comment out that field, the freezing doesn't happen.
If the characters are converted to Unicode, the freezing is also avoided.
For example, these special characters will always cause a freeze:
1️⃣
2️⃣
3️⃣
4️⃣
1⃣
2⃣
3⃣
4⃣
----
Here is my js:
```
function ExecuteScript() {
const blog_details = document.querySelector("xxx");
const blog_content = blog_details.querySelector("xxx").textContent;
const blog_date = blog_details.querySelector('xxx').textContent;
const comments_total = document.querySelector("xxx").textContent;
function escapeUnicode(text) {
return text.split('').map(char => {
const code = char.charCodeAt(0).toString(16).padStart(4, '0');
return '\\u' + code;
}).join('');
}
const escapedContent = escapeUnicode(blog_content);
const result = {
// blog_content: blog_content, // freeze
// blog_content: escapedContent // no freeze
blog_date: blog_date,
comments_total: comments_total
}
return JSON.stringify(result);
}
```
Is there a better solution for this, or is it a bug? Running the same JavaScript in the browser works fine.