正确加载网页的提示? [英] Tips for gracefully loading a web page?

查看:71
本文介绍了正确加载网页的提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网页有很多内容,当页面处于各种状态时,使用jQuery / javascript隐藏/显示/样式。我遇到了一个问题,其中在页面的初始加载,我的所有内容以可怕的方式显示了一秒钟,一切之前的样式/隐藏/显示如何应该在页面加载。



任何人都可以推荐任何技巧,以更优雅的方式初始加载页面。

解决方案

这被称为 FOUC - 一个没有花样的内容。



一个相当标准的方法是在你的css中默认隐藏内容,然后一旦所有使用javascript的操作完成再次显示元素。

$但是,您可以考虑尝试逐步增强,而不是针对优雅退化 >使javascript能够为您的网站添加功能,而不是依赖它的功能和外观。

请参阅这里有一个好的博客文章这两种方法的相对优点。


I have a web page that has a lot of content that is hidden/shown/styled when the page is in various states using jQuery/javascript. I am running into an issue where on the initial load of the page, all of my content is displayed in a hideous way for a fraction of a second before everything is styled/hidden/displayed how it should on page load.

Can anyone recommend any techniques to have the initial load of the page done in a more graceful way?

解决方案

This is known as a FOUC - a flash of unstyled content.

A fairly standard way is to hide the content by default in your css and then once all the manipulation using javascript has been done show the elements again.

However, rather than aiming for graceful degradation you may consider trying for progressive enhancement to enable javascript to add functionality to your site rather than relying on it for the functionality and appearance.
See here for a good blog post on the relative merits of the two approaches.

这篇关于正确加载网页的提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆