Using Character Set in the meta tag can decrease your page load speed. Follow the given method to avoid character set in the meta tag.
What is a “Meta Tag” ?
Meta tags are code snippets that provide important information about your HTML page to search engines and visitors. Meta tags represent meta data and they live within the HTML tags of your webpage. Meta description, Meta charset, Meta viewport, Meta http-equiv and Meta robots are some of the important meta tags. An example of a meta tag is as follow:-
< meta name="description" content="About this webpage">
What’s Character Set?
Character set (charset) consists of numbers, codes or bit patterns and is utilized by browsers to convert information into readable characters. How browsers will display the site to your visitors is depends on which character set you defined. There are many character sets that are in use.The default charset most popularly used in HTML5 is UTF-8. A few examples of charsets include:
- UTF-8 (Unicode)
- US-ASCII (basic English)
Using the wrong character encoding can cause some characters to display incorrectly in the browser.
You can find all character encodings in the IANA registry.
Normally, a character set is defined using a meta tag as follows:
For HTML 4:
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
For HTML 5:
Why avoid a ‘Character set’ in ‘Meta Tag’?
Many page speed testing tools recommends to avoid the character set in the meta tag, because specifying a character set in a meta tag disables the lookahead downloader in IE8. So you should avoid a character set in the meta tag in order to improve page speed metrics.
There are a few options available for defining a charset without using a meta tag. The best approach is to provide charset information in the HTTP header configuration. You can define the character set depending on your server-side language or web server. So, the character set will be displayed within the HTTP response header.
For Php pages:
header("Content-Type: text/html; charset=utf-8");
For Apache server, you can add the following line in your htaccess file:
AddType 'text/html; charset=UTF-8' html
For nginx, add following in your config:
more_set_headers -t 'text/html' 'Content-Type: text/html; charset=utf-8';
Do not forget to remove the charset meta tag from all your web pages. In case of WordPress, remove META tag from header.php file.