How to remove meta charset from document head

Community Forums Forums General Discussion How to remove meta charset from document head

This topic is: resolved


This topic contains 8 replies, has 3 voices, and was last updated by  eduardomachuca 2 years, 8 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
  • #29472



    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?



    Eduardo Machuca



    Here 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.

    Loving the Genesis Life!



    Thanks 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.

    &lt;pre class=&quot;line-pre&quot;&gt;
    &lt;div class=&quot;line&quot; id=&quot;file-functions-php-LC3&quot;&gt;remove_action( &#8216;genesis_doctype&#8217;, &#8216;genesis_do_doctype&#8217; );&lt;/div&gt;
    &lt;div class=&quot;line&quot; id=&quot;file-functions-php-LC4&quot;&gt;add_action( &#8216;genesis_doctype&#8217;, &#8216;child_do_doctype&#8217; );&lt;/div&gt;
    &lt;div class=&quot;line&quot;&gt;&lt;/div&gt;
    &lt;div class=&quot;line&quot; id=&quot;file-functions-php-LC5&quot;&gt;&lt;span style=&quot;font-size: 12px; line-height: 18px;&quot;&gt;function child_do_doctype() {&lt;/span&gt;&lt;/div&gt;
    &lt;div class=&quot;line&quot; id=&quot;file-functions-php-LC12&quot;&gt;
    &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;<a href=";&#038;gt" rel="nofollow">;&#038;gt</a>;
    &lt;html xmlns=&quot;<a href=";quot" rel="nofollow">;quot</a>; lang=&quot;en-US&quot; xml:lang=&quot;en-US&quot;&gt;
    &lt;head profile=&quot;<a href=";&#038;gt" rel="nofollow">;&#038;gt</a>;
    &lt;div class=&quot;line&quot; id=&quot;file-functions-php-LC18&quot;&gt;}&lt;/div&gt;
    &lt;div class=&quot;line&quot;&gt;


    Eduardo Machuca



    I copied/pasted the code from the article but it seems to have entered div markup. Trying again,

    &lt;code class=&quot;php plain&quot;&gt;remove_action( &lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#8217;genesis_doctype'&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#8217;genesis_do_doctype'&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;
    &lt;code class=&quot;php plain&quot;&gt;add_action( &lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#8217;genesis_doctype'&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#8217;child_do_doctype'&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;
    &lt;code class=&quot;php keyword&quot;&gt;function&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;child_do_doctype() {&lt;/code&gt;
    &lt;code class=&quot;php plain&quot;&gt;&lt;!DOCTYPE html PUBLIC &lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;&lt;/code&gt; &lt;code class=&quot;php string&quot;&gt;&quot;&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;<a href=";&gt;&lt;/code&gt;&lt;code" rel="nofollow">;&gt;&lt;/code&gt;&lt;code</a> class=&quot;php plain&quot;&gt;
    &lt;div class=&quot;line number8 index7 alt1&quot;&gt;&lt;code class=&quot;php plain&quot;&gt;&lt;html xmlns=&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;&lt;/code&gt;&lt;code class=&quot;php comments&quot;&gt;<a href=";quot" rel="nofollow">;quot</a>; lang=&quot;en-US&quot; xml:lang=&quot;en-US&quot;&gt;&lt;/code&gt;&lt;/div&gt;
    &lt;div class=&quot;line number9 index8 alt2&quot;&gt;&lt;code class=&quot;php plain&quot;&gt;&lt;head profile=&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;&lt;/code&gt;&lt;code class=&quot;php comments&quot;&gt;<a href=";&gt;&lt;/code&gt;&lt;/div&#038;gt" rel="nofollow">;&gt;&lt;/code&gt;&lt;/div&#038;gt</a>;
    &lt;div class=&quot;line number9 index8 alt2&quot;&gt;}&lt;/div&gt;
    &lt;div class=&quot;line number9 index8 alt2&quot;&gt;

    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



    Nope, all I have to do is enter the code into functions file, pasting even as plain text, and the site breaks.

    Eduardo Machuca



    Are 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!


    Gary Jones

    Don’t copy and paste from – click on the “view raw” link in the bottom right of the code snippet which takes you to a raw version of the Gist –

    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.

    Changes in Genesis 2.1 – the ultimate guide to every single change in Genesis Framework 2.1, 2.1.1 and 2.1.2 (all 90 of them!) | @GaryJ



    Thank 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( &#8216;genesis_doctype&#8217;, &#8216;genesis_do_doctype&#8217; );
    add_action( &#8216;genesis_doctype&#8217;, &#8216;child_do_doctype&#8217; );
     * Include Facebook Open Social namespaces.
     * @author Gary Jones
     * @link <a href="" rel="nofollow"></a>
    function child_do_doctype() {
    &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;<a href=";&#038;gt" rel="nofollow">;&#038;gt</a>;
    &lt;html xmlns=&quot;<a href=";quot" rel="nofollow">;quot</a>; lang=&quot;en-US&quot; xml:lang=&quot;en-US&quot;&gt;
    &lt;head profile=&quot;<a href=";&#038;gt" rel="nofollow">;&#038;gt</a>;

    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


    Eduardo Machuca



    By 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

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.