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

Tagged: 

This topic contains 8 replies, has 3 voices, and was last updated by  eduardomachuca 1 year ago.

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

    eduardomachuca
    Participant
    Post count: 6

    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

    #30691

    weslinda
    Participant
    Post count: 187

    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.

    http://code.garyjones.co.uk/modify-doctype


    Loving the Genesis Life!

    #30905

    eduardomachuca
    Participant
    Post count: 6

    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.

    <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

    #30906

    eduardomachuca
    Participant
    Post count: 6

    I 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"><a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" rel="nofollow">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>"></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"><a href="http://www.w3.org/1999/xhtml" rel="nofollow">http://www.w3.org/1999/xhtml</a>" 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"><a href="http://gmpg.org/xfn/11" rel="nofollow">http://gmpg.org/xfn/11</a>"></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

    #30907

    eduardomachuca
    Participant
    Post count: 6

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


    Eduardo Machuca

    #30924

    weslinda
    Participant
    Post count: 187

    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!

    #31031

    Gary Jones
    Moderator
    Post count: 635

    Don’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.


    Changes in Genesis 2.0 – the ultimate guide to every single change in Genesis Framework 2.0, 2.0.1 and 2.0.2 (all 159 of them!) | @GaryJ

    #31202

    eduardomachuca
    Participant
    Post count: 6

    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( 'genesis_doctype', 'genesis_do_doctype' );
    add_action( 'genesis_doctype', 'child_do_doctype' );
    /**
     * Include Facebook Open Social namespaces.
     *
     * @author Gary Jones
     * @link <a href="http://code.garyjones.co.uk/modify-doctype/" rel="nofollow">http://code.garyjones.co.uk/modify-doctype/</a>
     */
    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

    #31430

    eduardomachuca
    Participant
    Post count: 6

    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.