Browser & Web Performance · Senior · Question 50 of 75

What is DOM clobbering?

<a id="config" href="https://evil.example"></a>
<script>
  const url = window.config?.href || "/default.js";
</script>

Explanation

Even sanitized HTML without scripts can clobber globals. Avoid reading config from globals and use explicit declarations.

Further reading

Problem with a question

Browser & Web Performance · Senior · question 50

Test yourself

Take the Browser & Web Performance · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz