- 浏览: 1461825 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
luhouxiang:
写的很不错,学习了
Extjs 模块化动态加载js实践 -
kingkongtown:
如果想改成淘宝后台那样,可以在编辑器批量上传图片呢?
kissy editor 阶段体会 -
317966578:
兄弟我最近也在整jquery和caja 开放一些接口。在git ...
caja 原理 : 前端 -
liuweihug:
Javascript引擎单线程机制及setTimeout执行原 ...
setTimeout ,xhr,event 线程问题 -
辽主临轩:
怎么能让浏览器不进入 文档模式的quirks模式,进入标准的
浏览器模式与文本模式
Since 1994, the web development community has beaten graceful degradation ’s drum. A carry-over from the engineering world, the concept was, at its core, about giving the latest and greatest browsers the full-course meal experience while tossing a few scraps to the sad folk unfortunate enough to be using Netscape 4. It worked, sure, but it didn’t really match Tim Berners-Lee’s original vision for a universally accessible web.
About a decade later, several smart folks began to question graceful degradation and found it lacking on many levels. Concerned with content availability, overall accessibility, and mobile browser capabilities, they sought a new way to approach web development—a way that focused on the content and did more than just pay lip service to older devices.
At SXSW in 2003, Steve Champeon and Nick Finck gave a presentation titled “Inclusive Web Design For the Future .” There, they unveiled a blueprint for this new way of approaching web development. Steve also gave it a name: progressive enhancement .
There’s a (subtle) difference
In case you are scratching your head, trying to see how graceful degradation and progressive enhancement differ, I’ll say this: it’s a matter of perspective. Both graceful degradation and progressive enhancement consider how well a site works in a variety of browsers on a variety of devices. The key is where they place their focus and how this affects workflow.
The graceful degradation perspective
Graceful degradation focuses on building the website for the most advanced/capable browsers. Testing in browsers deemed “older” or less capable usually takes place during the last quarter of the development cycle and is often restricted to the previous release of the major browsers (IE, Mozilla, etc.).
Under this paradigm, older browsers are expected to have a poor, but passable experience. Small fixes may be made to accommodate a particular browser. Because they are not the focus, little attention is paid beyond fixing the most egregious errors.
The progressive enhancement perspective
Progressive enhancement focuses on the content. Note the difference: I didn’t even mention browsers .
Content is the reason we create websites to begin with. Some sites disseminate it, some collect it, some request it, some manipulate it, and some even do all of the above, but they all require it. That’s what makes progressive enhancement a more appropriate paradigm. It’s why Yahoo! swiftly adopted it and used it to create their Graded Browser Support strategy.
So how does it work?
Getting into the progressive enhancement mindset is quite simple: just think from the content out. The content forms the solid base on which you layer your style and interactivity. If you’re a candy fan, think of it as a Peanut M&M:
The Chocolatey Layers of Progressive Enhancement
Start with your content peanut, marked up in rich, semantic (X)HTML. Coat that content with a layer of rich, creamy CSS . Finally, add JavaScript as the hard candy shell to make a wonderfully tasty treat (and keep it from melting in your hands).
If you’re at all familiar with the web standards movement’s mantra—separation, separation, separation—this makes perfect sense. Web standards-based development has often been likened to a layer cake (or, if you want to get really fancy, a trifle ).
I prefer the Peanut M&M analogy, because in it, the layers envelop the content completely, in much the same way our styles and scripts wrap our content.
If you’ll indulge my food analogy a bit longer (I hope I’m not making you hungry), I’ll explain why this approach is better and how the layers interact within this paradigm.
The peanut
Some people like peanuts; in fact, some people prefer peanuts to Peanut M&Ms. Similarly, some folks (and things like search engine spiders) want just the content.
Then there are folks who can’t handle the chocolate and candy layers on top of the peanut (diabetics, for example). Like them, people on mobile devices or older browsers may not be able to see your pretty design or interact with your slick Ajax-driven interface.
Making sure your markup conveys the greatest level of detail about the content it wraps around is essential to offering a basic experience to these users.
The chocolate coating
Next, you can delicately dip your content into a warm bath of ambrosial CSS —but before you jump to the hard candy shell, there are some additional considerations.
There are folks who love chocolate covered peanuts. These folks are like the middle tier of users who have some level of CSS support, but may not have decent JavaScript support. Or they may work at a company where the IT security folks are more than a little phobic about JavaScript. For them, JavaScript may be disabled entirely.
Whether Goober -inclined or Goober -limited, these folks deserve to be catered to. There are several progressively-enhanced ways to apply styles to your content, and they will be the topic of the second article in this series.
The hard candy shell
Finally, you can introduce JavaScript into the mix. With the rich interaction possibilities it provides, as well as its ability to manipulate and interact with the content and presentation layers, JavaScript really is the ingredient that can pull a site together into an “experience.”
I’m not sure exactly how the hard candy shell is added to an M&M (my guess is that it’s another dip of some sort), but adding JavaScript-based functionality and interactivity to your websites is a breeze when you think progressive enhancement. And, in much the same way as M&Ms are available in a variety of colors, the JavaScript experience can vary based on the capabilities of the browser or device attempting to use it.
As you probably know, this type of development is called unobtrusive JavaScript. I’ll cover those techniques and practices in the third and final article in this series.
Putting it all together
Developing with progressive enhancement is actually quite simple once you understand the concept and begin putting it into practice; perhaps even simpler than making candy. The next two articles in this series will help you hone your progressive enhancement skills with CSS and JavaScript, and will show you how the philosophy translates into code.
从1994年开始,Web开发社区就敲响了优雅降级(Graceful Degradation) 的鼓声。这个概念来自工程世界,其核心理念是给最新最强大的浏览器全套餐式的体验,而给那些不幸还在使用Netscape 4的可怜人们只留些残羹冷炙般的基本功能。毫无疑问,这发挥了作用。但是它并不很符合Tim Berners-Lee(译注:万维网之父)关于普遍可访问性网络(Universally Accessible Web)的原始愿景。
大约10年后,一些聪明的家伙开始质疑优雅降级,发现它在很多层面上有不足之处。他们将精力集中在内容可用性(Content Availability)、总体可访问性(Overall Accessibility)和移动设备浏览器的能力上,寻找到了一条Web开发的新途径——此方法将内容作为关注焦点,而不只是对旧设备的支持嘴上说说却没有实际行动。
在2003年的SXSW 会议(译注:一个关于电影、音乐和交互的会议)中,Steve Champeon和Nick Finck做了一个名为 “面向未来的全方位Web开发 ” 的演讲。这样,他们揭示了这种Web开发新方法的蓝图。Steve还给它取了个名称:渐进增强(Progressive Enhancement )。
这里有个(微妙的)差别
如果你挠着头想弄清楚优雅降级和渐进增强的区别,我告诉你,这是一个关于视角的问题。优雅降级和渐进增强都考虑一个网页在各种设备的各种浏览器上如何良好运转。两者区别的关键在于它们各自关注的焦点,以及这种关注对工作流程的影响。
优雅降级的视角
优雅降级关注于在最先进/最全能的浏览器上构建网站。在被认为“老的”或能力不足的浏览器中的测试,经常要等到开发周期的最后一个环节才进行,并且通常限制在主流浏览器(如IE、Mozzila等)的前一个发布版本中。
在这种模式下,老的浏览器只可能提供差强人意(poor, but passable)的体验。或许会做些小补丁来适应某个特定浏览器,但这些浏览器毕竟不是关注的焦点,除了修正重大的错误,也不会再费多大的神了。
渐进增强的视角
渐进增强关注于内容。请注意区别:我甚至都没提及浏览器。
内容是我们最初创建网站的原因。有些网站传播内容,有些收集内容,有些请求内容,有些操作内容,有些网站以上所有功能都有,然而它们都需要内容。这就是渐进增加成为一种更适合的模式的关键所在。这也是Yahoo!迅速采纳这种模式并用它创建了分级浏览器支持(Graded Browser Support) 策略的原因。
它是怎样运作的
进入渐进增强的思维方法很简单:只要从内容开始往外想。内容形成坚实的基石,在此之上你才能添加样式和交互。如果你爱吃糖果,可以将它想像成一颗M&M花生巧克力:
(图示:渐进增强的巧克力层)
从你的内容花生开始,将其标记为富含语义的(X)HTML. 接着给内容裹上一层富含奶油的CSS. 最后,添加JavaScript作为糖果硬壳,这就做成了一颗可口无比的美味(并使得它不会在你手里融化)。
如果你非常熟悉Web标准化运动的口号——分离、分离、分离——这个类比就相当清楚了。基于Web标准的开发经常被比作夹心蛋糕 (或者,可以更富想像力地比作为松糕 (译注:一种多层蛋糕,可以夹水果、奶油、沙司等))。
我更倾向拿M&M花生巧克力来类比,因为它的外层把内容完全包裹住了,这和我们的样式与脚本将内容包裹起来几乎是一样的。
如果你允许我的食物类比论再多讲一点(希望不会让你感觉饥饿),我将解释为什么这种方式更好以及在这种模式下各层之间是如何交互的。
花生仁
有些人喜欢花生。实际上,有人喜欢花生胜过M&M花生巧克力。类似地,有些家伙(以及像搜索引擎爬虫这类东西)只想要内容。
还有些人无福消受花生上的巧克力和糖果层(例如糖尿病患者)。和他们类似,移动设备或老浏览器用户可能无法看到你漂亮的设计,或者与你流畅的AJAX驱动的界面交互。
确保你的标记能够将所包裹的内容的细节最大限度地传达出来,这对于给这些用户提供基本体验至关重要。
巧克力外衣
接下来,你可以将内容小心地浸入芳香美味的CSS暖浴中了。不过在你跳进糖果硬壳之前,还有些额外的考虑。
有的人爱吃巧克力裹着的花生。这些人就像中级用户,他们的浏览器有比较好的CSS支持,但可能没有很好的JavaScript支持。或者,可能在他们工作的公司里,IT安全人员对JavaScript极其病态性地恐惧。对他们来说,JavaScript就可能完全被禁用了。
无论是倾向于爱吃巧克力花生 (译注:一种直接用巧克力覆盖的花生,没有外层硬壳,类似于有内容和CSS但没有JavaScript支持的网站)还是被限制只能吃巧克力花生 ,这些人都应该得到满足。这里有几种渐进增强的方式可以将样式应用于内容,这将是本系列第二篇文章的话题。
糖果硬壳
最后,你可以将JavaScript添加到内容和样式的混合体中了。JavaScript提供了富交互的可能性,同时具有操作内容层和展现层并与其交互的能力,这实际上使得JavaScript成为了把网站带入“体验”高度的一味配料。
我不确定糖果硬壳到底是怎样添加到M&M花生巧克力上的(我猜是另一种什么浸蘸过程吧),但是,你脑中想着渐进增强的话,在你的网站上加入基于JavaScript的功能和交互就轻而易举了。另外,就如M&M花生巧克力有各种各样颜色一样,依据所运行的浏览器和设备的能力,JavaScript的体验也可以各不相同。
正如你可能知道的那样,这种类型的开发叫做无侵入式(Unobtrusive)JavaScript. 我将在本系列的第三篇和最后一篇文章中讲述这些技巧和实践。
都放在一起
一旦理解了渐进增强的理念并开始在实践中使用,那么用渐进增强进行开发就非常简单了。也许比做糖果还简单。本系列接下来的两篇文章将帮助你使用CSS和JavaScript来磨练你的渐进增强技巧,并向你展示怎样把哲学转换成代码。
~~~~~~
译注:
- Graceful Degradation有译为预留退路、平稳退化的,但我觉得这两个翻译没有表达原意,不如直接翻译成优雅降级的好。
- Unobtrusive有译为不唐突的、分离的、低调的,在Web开发领域,我觉得翻译成“无侵入的”最能表达原意。
2008年10月8日 射雕&安吉 译于杭州
2008年10月9日 审校
发表评论
-
continuation, cps
2013-09-12 16:49 2797起 随着 nodejs 的兴起,异步编程成为一种潮流 ... -
一种基于匹配回朔的 css3 选择器引擎实现
2013-05-07 20:40 3401一种基于匹配回朔的 css3 选择器引擎实现 介绍 C ... -
cubic-bezier 模拟实现
2013-01-05 16:34 14091cubic-bezier 曲线是 css3 动画的一个重要基石 ... -
构建前端 DSL
2012-10-11 22:10 5361目前在传统的软件开 ... -
Get cursor position and coordinates from textarea
2012-04-10 20:50 5047最近需要从 textarea 中获 ... -
兼容 ie 的 transform
2012-02-23 14:00 6428css 2d transform 是 css3 引入的一个新的 ... -
promise api 与应用场景
2012-02-07 17:34 7382promise 是 commonjs 社区中提出的异步规范,其 ... -
closure compiler 代码优化实例
2012-01-08 03:23 2832closure compiler 可以进行不少有意思的优化 ... -
write html parser
2011-12-01 02:48 2918首先需要声明 html 不能用正则表达式来直接匹配进行内容抽取 ... -
获取剪贴板数据
2011-11-07 23:31 6449兼容性: 获取剪贴板数据这块各个浏览器间存在很大的 ... -
url 映射问题
2011-11-07 21:52 3223背景 url mapping 我最早知道是作为 j ... -
tip:如何原生播放声音
2011-10-19 12:45 2980如果不想考虑浏览器间 ... -
转载:瀑布流布局浅析
2011-09-29 19:02 2847简介 如果你经 ... -
cross domain request
2011-09-29 18:39 2847场景 跨域请求是随着 ... -
基于多继承的树设计
2011-09-18 03:42 2269分类 树是一种常见 ... -
caja 原理 : 前端
2011-09-01 16:48 7051作为前端开放的基础安全保证,caja 是目前比较合 ... -
tokenization of html
2011-08-29 22:38 2789html 符号解析问题 场景: 在页面上输出包 ... -
ie 下 cloneNode 导致的属性克隆
2011-08-24 16:10 2478这个还是很值得记下,一直存在的很大隐患终于解决,由于在 ie& ... -
循环引用下的深度克隆
2011-08-04 20:39 2308深度复制和浅度复制 是当初初学 c 遇到的第一批问题,似乎使 ... -
模块的静态与动态循环依赖
2011-07-25 03:43 3281场景: 循环依赖 我是不支持的,但现实中似乎又确实需 ...
相关推荐
It’s both a practical guide to understanding the principles and benefits of progressive enhancement, and a detailed exploration of examples that will teach you—whether you’re a designer or a ...
《Adaptive Web Design: Crafting Rich Experiences with Progressive Enhancement》这本书详细介绍了渐进式增强(Progressive Enhancement)这一概念,并指导我们如何在设计和开发过程中运用它以创建能够适应不同...
本书记录了渐进增强的起源,其原理和机制,并揭示了无数实用方法,您可以使用HTML,CSS和JavaScript应用渐进增强原理。
渐进增强(Progressive Enhancement)是一种网页开发策略,旨在确保所有用户都能访问基本内容和功能,无论他们的设备、浏览器或网络连接如何。这种技术的核心思想是先构建一个基础版本的网页,然后逐步添加复杂性和...
Building Progressive Web Apps(EarlyRelease) 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
本篇文章将深入探讨如何使用Node.js来判断一张JPEG图片是否为渐进式(progressive)。 首先,我们需要了解什么是渐进式JPEG(Progressive JPEG)。JPEG是一种广泛使用的有损图像压缩格式,而渐进式JPEG则是JPEG的一...
存放Flash视频的文件夹,注意是相对flvplayer.swf文件的位置FLVPlayer_Progressive.swf
Progressive Web Apps are built with a collection of technologies, design concepts, and Web APIs that work in tandem to provide an applike experience on the mobile web. Progressive Web Apps takes ...
Focused on a feature-rich but lightweight codebase built on progressive enhancement with a flexible, theming system and ThemeRoller tool. The framework includes an Ajax navigation system that brings...
Focused on a feature-rich but lightweight codebase built on progressive enhancement with a flexible, theming system and ThemeRoller tool. The framework includes an Ajax navigation system that brings...
用progressive resizing提升CNN图像分类器性能,Boost your CNN image classifier performance with progressive resizing in Keras,by Aleksey Bilogur。
Progressive Web Apps 英文无水印原版pdf pdf所有页面使用FoxitReader、PDF-XChangeViewer、SumatraPDF和Firefox测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国...
Progressive Downloader 4.6 PSD Mac下载工具 MacOS系统工具
本文是使用 Ajax 改造现有 Web 站点系列的第一篇文章,将展示如何使用简单的...通过应用渐进增强(progressive enhancement)这一理念,能够保证这些增强的 UI 特性不会损害站点的可访问性,并且严格遵守 Web 标准。
Beginning Progressive Web App Development Creating a Native App Experience on the Web 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除
Building Progressive Web Apps(EarlyRelease) 英文mobi 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
在IT行业中,"Progressive Internet Explorer"这一概念可能指的是针对早期版本的Internet Explorer(如IE8)进行的渐进增强策略。渐进增强是一种网页开发方法,旨在确保即使在功能较弱的浏览器中,网站也能正常工作...
Progressive Web App(PWA)是一种新型的网络应用模型,旨在提供接近原生应用的体验,同时保持网页的可访问性和可发现性。在Python开发中,虽然PWA不直接与Python语言相关,但我们可以利用Python后端技术来构建支持...