Welcome to WebmasterWorld Guest from 54.167.29.212

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

htaccess UTF-8 encoding for .html, .css, .js - Whats the best way?

     

ewwatson

2:03 pm on Nov 14, 2012 (gmt 0)

5+ Year Member





For yslow page speed I want to remove my meta tag and put my encoding in the htaccess. These are all the ways I have read to do it. Which is the preferred way? Also is the language setting a good idea too? Thanks!

1) From html5 boilerplate

AddDefaultCharset utf-8
AddCharset utf-8 .html .css .js
DefaultLanguage en-US

vs

2) from askappache

<filesMatch "\.(html|css|js)$">
AddDefaultCharset UTF-8
DefaultLanguage en-US
</filesMatch>

vs

3) from askappache - I suspect this is all thats needed. But untested.

AddCharset UTF-8 .html .css .js
DefaultLanguage en-US

lucy24

8:09 pm on Nov 14, 2012 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



All header-based forms have one drawback: If someone saves your page locally (yes, this might be done for legitimate reasons, not just by scrapers) the page will not contain any text encoding information of its own. So it may display incorrectly.

How much does a charset meta tag add to page loading time? Or, more exactly: does reading a header take less time than reading a meta tag?

Depending on content, your css and js may not even need to be utf-8 encoded. I've got a lurking suspicion that ascii reads faster-- but only if the browser knows ahead of time that it's ascii. (For comparison purposes, I've only got one stylesheet that contains non-ascii information. I expected to use an entity but it didn't work.*)


* Pseudo-class content. It displayed the literal entity instead of the intended non-ascii character. Oops.

ewwatson

9:02 pm on Nov 14, 2012 (gmt 0)

5+ Year Member



Ya im going to keep my meta tag in my page too. For my testing purposes and as you said. Didnt think of that one. Apparently the browser is able to "look ahead" (IE8 term) and start parsing the page before it even reads it with the header info in place. Prob a 1/1000 time dif but oh well. I want that A page speed grade damnit! More reading has lead me to this code. I'm pretty certain this is all I need to serve all file extensions both rules...

AddDefaultCharset utf-8
DefaultLanguage en-US

SevenCubed

8:46 pm on Nov 26, 2012 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



AddDefaultCharset utf-8 in your .htaccess is the way to go if you want that 100% grade on something like yslow or google page speed. But, you also have to leave the meta version in place or your page will get an error warning of it missing when it's parsed with the W3C validator. So keeping both works -- that's what I use.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month