未加星标

Is it okay to build sites that rely on JavaScript?

字体大小 | |
[前端(javascript) 所属分类 前端(javascript) | 发布者 店小二05 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏

Nolan Lawson ignited a bit of web controversy when, during a talk at the Fronteers Conference in Amsterdam , he suggested that it's okay to build a website that doesn't work without javascript, and then followed up with a blog post in which he argued that narrow interpretation of progressive enhancement start with HTML, then add CSS, then add JavaScript doesn't really make a lot of sense.

So, given that nearly everyone has a JavaScript-enabled browser what with it being 2017 and everything, is it okay to build sites that don't work without it? We asked our panel of experts.

Point of failure

Consultant frontend architect Harry Roberts got straight to the point: "In a word: No. In many words: Full JS apps are fine provided that a) They have their first render on the server, and b) They give me some content if that JS fails to load. It's less about availability of JS, and more about not entrusting flaky network connections with delivering our entire app in one render-blocking package. That's the problem. Don't make JSyourapp's single point of failure."

(Sarcastically) Yes!

"As long as you're fine with thesite completely failing because the browser is too old, or too new, or the user's bandwidth istoo constrained, or the server hiccups, or a firewall's security policy blocks it, or a dependency goes sideways, or you accidentally drop a semicolon somewhere, then sure," says consultant and author Eric Meyer , "it's OK. What you build won't be a part of the web continuum, and it will be needlessly fragile, but that's a choice you can make."

Offline-first, first

It's all a matter of priorities, says the man who kicked off the debate in the first place, Nolan Lawson . "The question we should be asking ourselves is not how wellour sites work without JS, but how well they work under poor or nonexistent network conditions," he suggests. "These concerns are often conflated, but they're not the same. Every yearsmartphones represent an increasing share of web traffic, but mobile networks have not caught up.

21 top examples of JavaScript

"So offline-first treating the network as an enhancement with JS tools like Service Worker and IndexedDB has become the new standard for building fast, resilient websites. It is possible to do both traditional progressive enhancement and offline-first, but it's not easy. Weshould prioritise offline-first over works-without-JS."

As long as it's done well

For web designer and developer Lea Verou it's probably all right, with reservations. "For web apps (e.g. Google Docs), it's aloud 'Yes'," she says, "since their functionality cannot be replicated without JavaScript. For content-based websites, it gets a bit trickier. Sure, except for a few weirdos nobody disables JS anymore, and it is technically possible to make an accessible, lightweight site that depends on JS. Also, if there is a JS error anywhere, the content breaks, which is a terrible experience (not concatenating all JS files helps alleviate this a bit). So, I guess my answer is, yes ifdone really well; no otherwise."

Functionality before features

"The core functionality of any service on the web should be available to the widest number of people," says Jeremy Keith . "The best way to ensure this is to use the simplest possible technology for that core functionality. But once you've got that in place, you can go absolutely crazy with JavaScript ... including adding more functionality that requires JavaScript to work. I'm reminded of what Mat Marquis said when working on the Boston Globe site: 'Lots of cool features on the site don't work when JavaScript breaks; 'reading the news' is not one of them.'"

Power and responsibility

Developer evangelist Christian Heilmann suggests that the question isn't about JavaScript, it's more about responsibility and power. "You can create a solution delivering the most important use case using HTML and CSS and enhance with JavaScript. This could, however, be very basic and not what people expect nowadays.

"If you rely on JavaScript you have full control, but also full responsibility over the delivery and the error handling. Problems like flaky connections can't be solved without JavaScript. Our job on the web is to create experiences that are available and great to use. We do this by using all of our tools responsibly."

Does anything really need JavaScript?

"Your project may require client-side JavaScript," says Aaron Gustafson , author of Adaptive Web Design, "I'd arguemost don't. Most can benefitfrom client-side JavaScript to improve the user experience (including by providing a good offline experience), but creating anexperience that benefits from client-side JavaScript is not the same as creating one that requires it. It's an important distinction thatis often overlooked."

This article originally appeared in net magazine issue 288; buy it here !

Related articles:

本文前端(javascript)相关术语:javascript是什么意思 javascript下载 javascript权威指南 javascript基础教程 javascript 正则表达式 javascript设计模式 javascript高级程序设计 精通javascript javascript教程

主题: JavaJavaScriptCSSHTML
分页:12
转载请注明
本文标题:Is it okay to build sites that rely on JavaScript?
本站链接:http://www.codesec.net/view/534228.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 前端(javascript) | 评论(0) | 阅读(36)