Image flicker and prevention. Proper coding standards

I've been working with some basic animations lately and trying to follow good web practices at the same time. The problem I'm encountering is image flicker when not using a preset css method to hide the element before the page loads.

It's very easy to prevent the flicker by just hiding the element with my normal css and then revealing it with javascript, but that seems to me a horrible practice if someone has javascript disabled.

Should I use the HTML5 feature of putting <noscript> tags in the header and then use a separate style sheet to set the opacity and position to the final settings for users without javascript? Is that the most elegant solution?

I've started using the greensock (gsap) library to TweenLite.from , since I can just set everything to the final state in the css, but I get a slight image/text flicker the first time the page is loaded. I like this solution because I can set all of the css as it will be for someone with no javascript, and it allows me to easily animate from a point, to an existing point, instead of working backwards like I have to do with Javascript or jQuery. But, there's still that image flicker which isn't really acceptable. Would a page preloader solve this?

What is the generally agreed upon practice for this these days? I'm also worried about SEO and the consequences of setting stuff to visibility: hidden or display:none and then animating it in. Does the Google spider read javascript?

Here's an example of the screen flicker and animations I'm talking about.


Have a look at HTML5 Boilerplate and Modernizr.

  • http://html5boilerplate.com/
  • http://modernizr.com/
  • It ships with a smart solution to see if a client has JavaScript enabled in CSS.

    By default a class no-js is applied to HTML tag and it is then replaced by js by Modernizr. That way you can qualify your CSS selectors accordingly.

    Example CSS:

    .no-js .foo {  }
    .js .foo {  }
    

    This should execute fast enough that clients with enabled JavaScript don't see the no-js styles.

    References:

  • What is the purpose of the HTML "no-js" class?
  • https://github.com/Modernizr/Modernizr/blob/master/src/setClasses.js#L9
  • 链接地址: http://www.djcxy.com/p/96882.html

    上一篇: 这个HTML标签究竟做了什么?

    下一篇: 图像闪烁和预防。 适当的编码标准