Community Forums › Forums › Archived Forums › General Discussion › How to remove meta charset from document head
Tagged: charset
- This topic has 8 replies, 3 voices, and was last updated 11 years, 1 month ago by eduardomachuca.
-
AuthorPosts
-
March 19, 2013 at 1:19 pm #29472eduardomachucaMember
Hola,
I'm using Modern Portfolio theme, and the google speedpage test recomended to remove the following:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
I edited the htaccess file and added AddDefaultCharset UTF-8 at the end. Google's speedpage test now passes but other tests still see the meta tag and recommend removing it:
"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."
So, how can I remove the charset meta tag line?
Gracias,
Eduardo
eduardomachuca.com
Eduardo Machuca
March 23, 2013 at 9:41 am #30691weslindaMemberHere is a quick little tutorial on how to edit this information. One thing I would say is that this isn't really anything major when it comes to speed.
http://code.garyjones.co.uk/modify-doctype
Loving the Genesis Life!
March 24, 2013 at 10:37 am #30905eduardomachucaMemberThanks for the code! Yet, if I enter it into my theme's (modern portfolio) functions.php file, the site breaks with a 500 server error. All I'm doing is replacing the code with my theme doctype info, and deleting the http-equiv charset meta tag line; charset declared in the htaccess file.
I was told, long time before, to enter php code into the functions file without the php markups, as show below. But even if I enter the code as in the article, the website also breaks.
I have added other code snippets to the functions file, from studiopress, and the site has been working fine.
* removing the author's comments/link just for clarity.
<pre class="line-pre"> <div class="line" id="file-functions-php-LC3">remove_action( 'genesis_doctype', 'genesis_do_doctype' );</div> <div class="line" id="file-functions-php-LC4">add_action( 'genesis_doctype', 'child_do_doctype' );</div> <div class="line"></div> <div class="line" id="file-functions-php-LC5"><span style="font-size: 12px; line-height: 18px;">function child_do_doctype() {</span></div> <div class="line" id="file-functions-php-LC12"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US"> <head profile="http://gmpg.org/xfn/11"> </div> <div class="line" id="file-functions-php-LC18">}</div> <div class="line">
Gracias,
Eduardo Machuca
March 24, 2013 at 10:45 am #30906eduardomachucaMemberI copied/pasted the code from the article but it seems to have entered div markup. Trying again,
<code class="php plain">remove_action( </code><code class="php string">'genesis_doctype'</code><code class="php plain">, </code><code class="php string">'genesis_do_doctype'</code> <code class="php plain">);</code> <code class="php plain">add_action( </code><code class="php string">'genesis_doctype'</code><code class="php plain">, </code><code class="php string">'child_do_doctype'</code> <code class="php plain">);</code> <code class="php keyword">function</code> <code class="php plain">child_do_doctype() {</code> <code class="php plain"><!DOCTYPE html PUBLIC </code><code class="php string">"-//W3C//DTD XHTML 1.0 Transitional//EN"</code> <code class="php string">"</code><code class="php string">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></code><code class="php plain"> </code> <div class="line number8 index7 alt1"><code class="php plain"><html xmlns=</code><code class="php string">"</code><code class="php comments">http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US"></code></div> <div class="line number9 index8 alt2"><code class="php plain"><head profile=</code><code class="php string">"</code><code class="php comments">http://gmpg.org/xfn/11"></code></div> <div class="line number9 index8 alt2">}</div> <div class="line number9 index8 alt2">
Hmmm, probably that's what happening to my site when I paste the code (it's probably pasting hidden markup?). Will check now.
Eduardo Machuca
March 24, 2013 at 10:51 am #30907eduardomachucaMemberNope, all I have to do is enter the code into functions file, pasting even as plain text, and the site breaks.
Eduardo Machuca
March 24, 2013 at 12:03 pm #30924weslindaMemberAre you entering the first <? php tag? If so, you'll want to skip that. Also, you'll want to edit the actual doctype information for your needs. Beyond that, you might want to post a screenshot of the edited file so we can see what's actually being uploaded.
At the end of the day, I'll tell you that this isn't going to really make much of a difference when it comes to speed rankings of your site.
Google likes to recommend lots of things, and they aren't law, just suggestions.
Loving the Genesis Life!
March 24, 2013 at 8:14 pm #31031Gary JonesMemberDon't copy and paste from garyjones.co.uk - click on the "view raw" link in the bottom right of the code snippet which takes you to a raw version of the Gist - https://gist.github.com/GaryJones/1707880/raw/b635e56d6b4a6b3d40b9c5c8a25c5eb94ca13417/functions.php
Copy all but the opening <?php line and paste into the end of your child theme functions.php file. Then delete or amend the charset or bit you don't want.
WordPress Engineer, and key contributor the Genesis Framework | @GaryJ
March 25, 2013 at 5:16 pm #31202eduardomachucaMemberThank you all. Just tested and worked. I was missing the php markups within the function; I was removing all markup. It finally looks like this (with my own theme's doctype):
remove_action( 'genesis_doctype', 'genesis_do_doctype' ); add_action( 'genesis_doctype', 'child_do_doctype' ); /** * Include Facebook Open Social namespaces. * * @author Gary Jones * @link http://code.garyjones.co.uk/modify-doctype/ */ function child_do_doctype() { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US"> <head profile="http://gmpg.org/xfn/11"> <?php }
And added to my htaccess file:
# add default charset utf-8 <filesMatch ".(htm|html|css|js|php)$"> AddDefaultCharset UTF-8 DefaultLanguage en-US AddType 'text/css; charset=UTF-8' .css AddType 'application/x-javascript; charset=UTF-8' .js </filesMatch>
Gracias,
Eduardo Machuca
March 26, 2013 at 5:14 pm #31430eduardomachucaMemberBy the way, before even making these changes, I've noticed that on ie10 pages had strange characters on the text, but not on Chrome. Made these changes thinking it will solve that but not.
After testing found that ie10 was automatically selecting the encoding as Occidental European (Windows), instead of Unicode UTF-8. I had to manually select UTF-8 to see the page text correctly.
Made more testing and finally found out that it was the W3TC plugin. Disabling it corrected the problem (purging all caches did not fix the problem), and ie10 was able to correctly and automatically encode the page as UTF-8. So, I now have deleted the W3TC plugin from my site.
Eduardo Machuca
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.