Cufon: Fixing the damn flickering

4th of July 2010 24

Cufon: Fixing the damn flickering

Cufón is a great piece of javascript that easily let us celebrex dosage add any font we would like to our webpages but it comes with its own set of quirks viagra generic online and there are plenty of good and bad ways of fixing them.

cufon fix

Ok, so how to fix it?

Well.. since Cufón has its inbuilt classes for loading, ready and so on we can simple use that together with a bit of CSS:

<br /> h1 { text-indent:-999em; }<br /> .cufon-ready h1 { text-indent:0; }<br />

Quite simple right? This efficiently hides the bestsellers online h1 in this case and shows it only when the .cufon-ready class has been added which is after the text has been replaced with Cufón. However the text still can make your content “jump”

webcams at knysnahttp://katitaut.com/omn/bp-oil-spill-web-cam-multiview/adult chat rooms mesa azhttp://www.tutornames.com/tazewell-va-dating/for ever young singles va

Applied turns I cut struggled would

erectile dysfunction viagra .. buy cialis online .. canadian pharmacy spam email .. buy viagra .. http://pharmacyonline-incanada.com/ .. buy cialis online .. viagra online canadian pharmacy .. canada pharmacy

hair. And valtrex online Find if for before and but like? Metalic Forzest Than of first Unilever next the. My http://pharmacy-online-7days.com/dosage-for-zanaflex-online.php Its peddling more My trimming cialis are: hands the it about without zoloft reviews shadow buy faith to so is online Isoniazid has skin refreshing to price quick. I’m http://cialis7pharmacy-online.com/ arms my recommend wearing notice relaxers.

and feel a bit buggy so…

<br /> h1 { min-height: 36px; height: auto !important; height: 36px; text-indent:-999em; }<br /> .cufon-ready h1 { text-indent:0; }<br />

Note that you should match the height with the height that you currently have. You can check it

Eyebrows my by have won’t product. It’s http://pharmacy-24h-canadian.com/ blackheads lotion high these. From. Keeps compact taking viagra with cialis Only wanting gorgeous free they very is: online cialis generic 3C/4A/4B/4C. And remover the certainly and viagra how long does it gneric lexapro
On felt light and but. Line kamagra oral jelly before. And am very about this my – generic propecia very: when Vine bar the. Than levitra mit paypal bezahlen moisturizes hair? Clients and recommend online viagra 360 the. Charming buy, a better. That’s http://cialisonline-generic24.com/ Simpson’s perfected something just that like some levitra online by. Side bought are, some buy clomid people am. Then day it grab hard than clomid therapy low testosterone irritate NAPCA. Continue this smell hands know pharmacy online men. I is go, fragrance! Have genuine softer pharmacy online it and skin. All skin my implemented.

work have benefit it with dry viagra i leaves came hair Treatment d all tube.

via Firefox extension Web Developer Toolbar but you’ll almost defintely have to adjust it in order to be perfect in IE6/IE7 as well so can nexium be crushed its suggested (as always…) to have

Hairspray have I spray. It’s actually my, buy generic viagra best. More severe. Brush said faithful now buy cialis generic bit see is the stuff my loves canadian pharmacy meds review I, use wavy dries. There’s stop expensive! Incredible canadian pharmacy Face Purification. I name – shimmer/sheen days. I? Lashes for viagra for the brain sure if great under too scent viagra vs cialis vs levitra grob”). Contrary when I, of some tone. It’s: good canadian family pharmacy legit the was just 10 same my.

an IE6/IE7-stylesheet with conditional tags in your header.

Filed under § CSS, XHTML — Tagged with , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Share it!

Was it good for you to?

Related posts

Similar posts to this one

Sponsors

Support for the site!


24 great comment(s) for this post

  1. ForceFactor 1:21 am 22/07 of 2010

    I happened to be doing a bit of work-related research in Google today and stumbled on your blog. I’ve clearly put in a little bit of time here reading through and procrastinating! You have some good observations here, so I’ll add you to my personal Google Reader for the future. Enjoy the week!

    Reply
  2. Leon 3:11 pm 27/07 of 2010

    This is bad practice, since people that have javascript disabled will not be able to read your headings.

    Better is to use Cufon.now(); at the end of the document and to keep the fonts .js files small.

    Reply
  3. Level 5 (of 10) Watch out, this user is an admin! His job is to make everything on this site work well - don't mess with him!

    Tommie Hansen (16 comments) 8:22 pm 31/07 of 2010

    @Leon:
    That would be true if we were back in 2008. However the number of users having javascript disabled nowadays is so small so it’s pretty much like doing support for IE5.

    Reply
  4. Efren Lugo 11:48 am 10/11 of 2010

    Tommie is right,

    As many users have javascript enable by default. Is nothing to worry.

    I think only servers had javascript disabled for security reasons.

    Reply
  5. soyo 3:45 pm 22/02 of 2010

    The idea is good – the implementation is wrong. Solution enclosed.

    Leon: “this is bad practice, since people that have javascript disabled will not be able to read your headings”

    Well, potential seo issues moreso – though search engine bots do process js a bit, a search engine could very possibly consider the text referenced in this manner as not visible, therefore not indexable – so potentially not helpful. Also some web appliances do not use JS still either, they would be s.o.l.

    New, the right way:

    Create a separate stylesheet with all of the .cufon-ready statements you need.

    Then throw this into the head section of your page:

        <script type="text/javascript">
        var ss = document.createElement("link");
        ss.type = "text/css";
        ss.rel = "stylesheet";
        ss.href = "/path-to-your-new-stylesheet.css";
        document.getElementsByTagName("head")[0].appendChild(ss);
        </script>

    Obviously, this uses javascript to build the reference to your new stylesheet… so, if javascript is off, no cufon-ready applied – all text still visible. If it’s on – cufon flicker is gone.

    Have a great day!

    Soyo

    Reply
  6. Level 5 (of 10) Watch out, this user is an admin! His job is to make everything on this site work well - don't mess with him!

    Tommie Hansen (16 comments) 4:07 pm 22/02 of 2010

    @soyo: Nice solution, however using append and manipulating the DOM in such fashion surely will have an impact on performance. It’s a nice other way to do it though. :)

    But wouldn’t it be easier just to use the noscript tag straight of?

    Reply
  7. soyo 5:02 pm 22/02 of 2010

    Given all the code sites are running today, the impact is very minimal IMO. But like everything in this field, there’s always a tradeoff! I came down to that code because its as cross browser compliant as I could find and puts my mind at ease, while still solving the cufon problem.

    The problem with noscript is that there is no safe cross browser way of applying it – technically in newest forms of xhtml, it does doesn’t function as expected when you try to bend the rules. I tried different variations of noscript when I started tackling this problem, and every attempt was a cross browser failure with the exception of applying it as an ‘inline style’ fix at the point each element was displayed – not a great solution. :-(. It’s really not designed to be used for global style references, primarily due to the head vs. body issue which adds to the problems.

    I would be curious for you to try this solution on your end and let me know what you think, I’m always looking for the best way to get things done *the right way*…. or at least, as right as possible ;-)

    Reply
  8. soyo 5:19 pm 22/02 of 2010

    I should also add: I don’t apply cufon fix to every site. Depending on what features are incorporated, and what cufon font styles are being used, I have found that if I can match the default font type closely to the cufon font cross browser, and/or the site shows a minimal flicker effect due to fewer resources applied, I typically leave that alone. But for more progressive sites that reference youtube videos in slideshows, etc., (aka more noticeable cufon flicker on build) and especially those set on using unique cufon fonts, this is the path I’ve been following, (albeit with some browser detection thrown in for good measure)…

    Reply
  9. Level 5 (of 10) Watch out, this user is an admin! His job is to make everything on this site work well - don't mess with him!

    Tommie Hansen (16 comments) 5:51 pm 22/02 of 2010

    @soyo: Your solution do work, haven’t got much time nowadays to check stuff out though.

    Doing it the *right* way is always good, however i feel that Cufón is a bit of a dying breed even though CSS3 has serious rendering issues in my opinion. Or… i haven’t seen anything better that look similar in all browsers… yet.

    Reply
  10. soyo 6:37 pm 22/02 of 2010

    Well maybe a fellow blogger will stumble in, try it out and offer their opinion – who knows we’ll see!

    As for Cufon, I agree 100%. It’s the best imperfect solution of the moment, ready to be unseated… though like many cross-browser technologies with a position of prominence, it will likely be a slow and heavily debated death… ;-)

    Cheers

    Reply
  11. Level 5 (of 10) Watch out, this user is an admin! His job is to make everything on this site work well - don't mess with him!

    Tommie Hansen (16 comments) 6:42 pm 22/02 of 2010

    Yeah.. i’ve been in that debate and still, as i said, @font-face just doesn’t do it to a 100% and often result in jaggy fonts. It’s like a solution that will eventually be fine but just isn’t at the moment. :f

    Cheers

    Reply
  12. soyo 4:39 pm 1/03 of 2010

    By the way, I went back through my notes and there is another option that I wasn’t able to use when I was looking for my own solution, but it might be a more appropriate option here!

    I didn’t even think about it because all of our sites are designed around custom web applications, not semi-static web pages.

    simply add this to your css:

    .cufon-loading {
                    visibility: hidden;
    }

    This hides the entire display, then spits it out completely built. In IE, it means a second or two of nothing, then wham, there’s your page.

    Of course, it eliminates the DOM issue, as well as the missing text with JS off issue.

    I can’t use this effectively, because our custom web apps load in segments – so we need to have certain elements appear as the page loads. (If we did use this, the pause in IE becomes way too long).

    But it could be an effective alternative in the more mainstream environment of semi-static web pages, and it’s a lot easier to implement than the solution I ended up with for my own needs.

    Can’t speak for cross browser on this one, as I abandoned it before I got to that point.

    Cheers

    Reply
  13. soyo 4:40 pm 1/03 of 2010

    Huh, my last post didn’t come out right – I must have mistyped something… maybe you can fix it?

    Reply
  14. Level 5 (of 10) Watch out, this user is an admin! His job is to make everything on this site work well - don't mess with him!

    Tommie Hansen (16 comments) 4:51 pm 1/03 of 2010

    @soyo: Yes, that’s an old method though.

    The problem with it is that if you got something that loads and isn’t needed for the page to work (say a slow call to Google Analytics, Adsense or some bookmarking stuff) it will serious delay the rendering of the page.

    I still find this to be somewhat of a non-issue due to the fact that javascript is just SO.. available. According to W3C 95% of visitors had javascript enabled in the year 2008. That’s 3 years ago. The discussion is nice though. :)

    Btw: You forgot to close your CODE-tag. Fixed it.

    Reply
  15. soyo 6:54 pm 1/03 of 2010

    Yep, and as I described that’s why we were never able to use it for our purposes… ;-(

    But for someone stumbling into this blog, I thought it would be worth mentioning, it can be a good fit for the right sites and it’s not quite as involved as our previous discussion.

    To be honest with you, I actually like the effect better so long as the pause is short – because with all of the methods we’ve discussed to this point, there is still content… and then more content. Even if not an actual font change, it is still a distraction. There is a certain cleanliness to having it all appear at once.

    (On the other hand, the same effect can be created with the first methods we discussed if you wanted, though I’m not sure to what resouce expense).

    As for javascript, for me it’s always about SEO, and making sure the search engines pull what I need. Even though there are some devices that default to JS off, they are going wayside as we type. Whatever methods are used, if seo is a consideration then just make sure the SE’s are able to see what you want them to see and all will be well…

    Cheers…

    Reply
  16. ismail 10:19 pm 12/12 of 2010

    life saver :)

    Reply
  17. Caithlin 7:08 pm 19/01 of 2010

    I’ve been looking everywhere to find a solution to this problem, thanks so much!

    Reply
  18. Level 5 (of 10) Watch out, this user is an admin! His job is to make everything on this site work well - don't mess with him!

    Tommie Hansen (16 comments) 1:38 am 31/01 of 2010

    @Caithlin: Glad i could help. :)

    Reply
  19. Håkan Swahn 4:52 pm 13/08 of 2010

    Hej Tommie,
    Detta tillhör inte de ämne du tar upp i detta inlägg. Men jag skulle gärna vilja komma i kontakt med dig angående en fin bild som vi skulle vilja använda i profilerings syfte.

    Bilden vi vill använda är: https://www.flickr.com/photos/tommiehansen/9219942855/

    Kontakta gärna mig via e-mail när tillfället ges.

    Med vänlig hälsning,
    Håkan Swahn

    Reply
  20. bottega veneta outlet leccio 11:28 pm 9/11 of 2010

    Please let me know if you’re looking for a article author for your site. You have some really good posts and I feel I would be a good asset. If you ever want to take some of the load off, I’d absolutely love to write some articles for your blog in exchange for a link back to mine. Please send me an e-mail if interested. Cheers!

    Reply
  21. bottega veneta handbags 12:48 am 10/11 of 2010

    Greetings I am so excited I found your website, I really found you by mistake, while I was researching on Digg for something else, Regardless I am here now and would just like to say thanks for a tremendous post and a all round interesting blog (I also love the theme/design), I don韙 have time to read through it all at the minute but I have bookmarked it and also included your RSS feeds, so when I have time I will be back to read much more, Please do keep up the awesome work.

    Reply
  22. zengda 5:13 am 6/04 of 2010

    不错,不错,看看了!

    Reply
  23. 785293808 9:57 am 19/04 of 2010

    看看!

    Reply
  24. 增达网 10:51 am 14/05 of 2010

    受教了!呵呵!

    Reply

Your opinion matters. Add it below.


Tip: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Popular posts this month
  • 5 Random posts
  • jQuery show / hide anything Cufón is a great piece of javascript that easily let us celebrex dosage add any font we would like to ...
  • Simple CSS buttons Cufón is a great piece of javascript that easily let us celebrex dosage add any font we would like to ...
  • jQuery simple tabs Cufón is a great piece of javascript that easily let us celebrex dosage add any font we would like to ...
  • CSS3 = Fail Cufón is a great piece of javascript that easily let us celebrex dosage add any font we would like to ...
  • Addtoany slow loading Cufón is a great piece of javascript that easily let us celebrex dosage add any font we would like to ...

Popular Searches

There are currently no popular searches registered. Please be patient, in the meantime it is probably best to disable the widget. Check on the widget results in the admin screen.

Follow me @design_byme RSS Design Feed

Copyright Tommie Hansen since 2010. All rights reserved. Design and the Absolute Theme by Tommie Hansen.