---
title: "Discussion on \"A benchmark of different methods to empty an HTML element\" | Hashnode"
description: "Discussion on \"A benchmark of different methods to empty an HTML element\". function empty(element) {\n    if (element.innerHTML) {\n        element.innerHTML = \"\";\n    }\n}\n\nfunction empty1(element) {\n    element.innerHTML = \"\";\n}\n\nfunction empty2(element) {\n    while (element.firstChild) {\n        element.removeChild(element...."
url: "https://hashnode.com/posts/empty-element-benchmark/65980fcc3784f64f4a792b51"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [A benchmark of different methods to empty an HTML element](https://blog.shmovahhedi.com/empty-element-benchmark?utm_source=hashnode&utm_medium=feed)

function empty(element) { if (element.innerHTML) { element.innerHTML = ""; } } function empty1(element) { element.innerHTML = ""; } function empty2(element) { while (element.firstChild) { element.removeChild(element....

Jan 5, 2024 · 1 min read · blog.shmovahhedi.com  
Read the article

## Written by

[Shahab Movahhedi](https://hashnode.com/@movahhedi)

@movahhedi · Tehran, Iran 🇮🇷

  
[View profile](https://hashnode.com/@movahhedi)

Senior Developer, Designer, Technologist! 🇮🇷

Senior Developer, Designer, Technologist! 🇮🇷

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
