صفحه اصلی پورتال > مرکز آموزش > هاستینگ > Scripts > Avoid Meta Charset Tag for IE8


Avoid Meta Charset Tag for IE8




Avoid a character set in the meta tag

So you run your test on Gtmetrix and you notice a recommendation that says Avoid a character set in the meta tag and now you’re like, what the hell does that even mean?

Gtmetrix says:

The following resources have a character set specified in a meta tag. Specifying a character set in a meta tag disables the lookahead downloader in IE8. To improve resource download parallelization, move the character set to the HTTP Content-Type response header.

If you look at your source code, it is almost certain that you have something like this in your header.

<meta charset="UTF-8">

Now you might be thinking, ok well I will just remove it, job done.

Well, not quite.

You see there is a good chance that you actually need it and the reason for that is there is also a very good change your running an Apache web server.

By default Apache serves files in ISO-8859-1 which is laymen terms means it cannot encode all the wonderful characters we all love to use on our modern websites.

ISO-8859-1 vs UTF-8

Wikipedia gives you a pretty good idea about what they are, however I am quite sure that most of you don’t want to go and read any of that crap.

So I will break it down and pick out the important differences.

ISO-8859-1

  1. ISO-8859-1 is the Latin-1 (western European languages) encoding.
  2. The first 128 characters are the standard ASCII set which includes the Arab numerical system of (0 – 9), uppercase and lowercase English alphabet and a few special characters.
  3. All characters in this family are single byte.
  4. The upper echelons of this character set, i.e. (160 – 255), include special characters and symbols used throughout Western Europe, example – ® or Ô to name but a few.

UTF-8

  1. UTF-8 is the the mother of all Character Sets. It encompasses every Major Alphabet and many minor ones in to a single Character set.
  2. As with ISO-8859-1 the first 128 characters are the standard ASCII set.
  3. Here is where things get a little more interesting. UTF-8 is backwards compatible and  can encode all ISO-8859-1 characters which are single byte.  But it can also encode multi-byte characters which expands its arsenal of characters way beyond that of ISO-8859-1.
  4. It is used by more than half of all websites, it is also increasingly being used across other platforms such as operating systems.
  5. The Internet mail Consortium (IMC) recommends that you only use UTF-8 for sending mail.

So we can clearly see that UTF-8 has a clear advantage over ISO-8859-1 and I would highly recommend that you use it.

Now in order to ensure your character set is set to UTF-8 we can add a simple line to the top of .htaccess

# pass the default character set
AddDefaultCharset utf-8

What this line does is simply define UTF-8 as the default character set. You can keep the meta tag variant, but by adding the above line to .htaccess we are fixing the issue with Internet Explorer 8 as well as the recommendation by Gtmetrix.


source : http://diywpblog.com/avoid-a-character-set-in-the-meta-tag




آیا این پاسخ مفید بود؟

افزودن به علاقه مندی ها افزودن به علاقه مندی ها    چاپ این مقاله چاپ این مقاله

خوانده شده

زبان: