---
schema_version: "1"
id: eeee04e7c9aea406cfb0ad6bc4bf083440a99411e4d71d803da528d8a3a6ba55
title: Optimize HTML
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/salesforce-pages-developers-guide/guides/pages/best-practices/best-practices-performance/pages-best-practices-perf-html.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-pages-developers-guide/guide/pages-best-practices-perf-html.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: bf43c18699b806ffcc13cefa332efa49b83067f6beef13c4bc5b78c64ec077eb
products:
  - Visualforce Developer Guide
  - Platform Developer Content
---

# Optimize HTML

On the server side where Visualforce validates HTML, optimized HTML improves processing efficiency. On the client side, optimized HTML makes a Visualforce page more responsive in the user’s browser.

To optimize the HTML in a Visualforce page:

-   Review the HTML that Visualforce components generate. Visualforce pages correct invalid HTML during compilation, which can cause the HTML to render in unintended ways. For example, if you have a `<head>` or `<body>` tag inside of your `<apex:page>` tag, the Visualforce page removes it at run time.
-   Review Ajax code. During an Ajax request, to ensure that the response properly fits back into the DOM, the server validates and corrects inbound HTML. Processing time decreases if your Visualforce page contains valid markup and if corrections are unnecessary.
-   Reduce HTML bloat. Although the browser caches HTML and compiled Visualforce tags, retrieving them from the cache impacts performance. Unnecessary HTML also increases the size of the component tree and the processing time for Ajax requests.

