TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

You might not need JavaScript

649 pointsby MarkusWinandover 8 years ago

54 comments

nfriedlyover 8 years ago
When I was hired on the Watson team, the first thing they asked me to do was help improve performance of their AngularJS-based website. It was all-around slow, especially for the initial page view. I stripped out AngularJS and most of the other JavaScript, and published a website that was almost pure static HTML. It loaded very quickly. My manager thought it was hilarious - his "JavaScript expert" came in and deleted all of the JavaScript.
评论 #12694411 未加载
评论 #12692675 未加载
评论 #12693405 未加载
评论 #12694449 未加载
评论 #12692789 未加载
评论 #12695760 未加载
评论 #12694471 未加载
评论 #12713344 未加载
评论 #12707334 未加载
评论 #12693894 未加载
BinaryIdiotover 8 years ago
So let&#x27;s show off what you can do without JavaScript...but also include SCSS as a dependency when the opening paragraph complains about a JavaScript dependency? Madness...but I digress.<p>Some of these are cool examples. Others, like the modal, won&#x27;t scale very well because now you can trigger modals by tabbing (breaks keyboard navigation) or most of the form examples as you&#x27;ll likely hit many endpoints that require JSON (which yeah I know &quot;you&#x27;re making a web app why can&#x27;t your endpoints accept a form?&quot; but as we all know it&#x27;s never that simple and you might want to provide different behaviors for, say, showing a progress bar or disabling certain features during the submissions or a THOUSAND other things).<p>I get axing dependencies. I really do. I wrote msngr.js entirely in ECMAScript 5 using zero dependencies so I&#x27;d have the most flexibility possible. But at the same time overcomplicating your code to the point where it&#x27;s breaking standard practices or making it un-maintainable <i>simply</i> to axe a dependency is the wrong way to go.<p>But by all means keep making cool stuff that shows off how versatile CSS is! Just don&#x27;t expect to use all the CSS tricks you learn in a production environment.
评论 #12691504 未加载
评论 #12691600 未加载
评论 #12694257 未加载
评论 #12691428 未加载
评论 #12691420 未加载
IanCalover 8 years ago
I&#x27;m cautious about using CSS to do things that feel like actual behaviours.<p>For example, the modal that appears when you click on the button actually doesn&#x27;t do things on &quot;clicking&quot; but <i>focusing</i>. This means if you tab over the button it&#x27;ll load the modal, then tabbing away means the modal is gone. I can&#x27;t tab into the content in the modal at all. How does that work with accessibility?<p>Though I generally dislike the idea of saying content isn&#x27;t there by making it <i>present in the document</i> but <i>invisible</i>.<p>Edit - Some of the default behaviours are also a bit pants. In chrome, the form validation on a pattern starts working after I hit submit, then angrily shakes at me for every keypress until it&#x27;s valid. Then, it ignores invalid input as I type more! Please never use this for phone numbers or credit card numbers. Stop requiring an exact format when what people type varies, and stop telling me I&#x27;m putting in something wrong when you ask for a phone number and I give you something that&#x27;ll connect to me if you type into a phone.<p>Maxlength is not a validation it&#x27;s just ignores any more letters you type. Quietly ignoring your users input is probably not what you want.<p>The &quot;Would you prefer a banana or a cherry?&quot; just shouts &quot;Please match the requested format&quot; if I type &quot;a cherry&quot;. I know chrome has nothing else to go on other than &quot;the regex wasn&#x27;t matched&quot; but it&#x27;s a bad end user experience.<p>The tabs example is something I need to tab onto then use left and right, I assume because it&#x27;s a radio box underneath, not a series of links. Are tabs really radio buttons?<p>The same for the accordion. Which I&#x27;ve found if I add any tabbable content inside them then I&#x27;m focused on a <i>hidden item</i>. Great. Tab onto &quot;tab 1&quot;, hit tab, focus has disappeared and I&#x27;m now potentially going to click on random items I can&#x27;t see. This is because although you want to pretend the content isn&#x27;t there just because it&#x27;s not visible, it&#x27;s still there! It&#x27;s in your document.<p>Sure, you might not <i>need</i> javascript. But maybe you should still use it.
评论 #12691694 未加载
NKCSSover 8 years ago
It made me learn about <a href="http:&#x2F;&#x2F;caniuse.com&#x2F;#feat=input-pattern" rel="nofollow">http:&#x2F;&#x2F;caniuse.com&#x2F;#feat=input-pattern</a> ; thanks for that!
评论 #12691409 未加载
jwblackwellover 8 years ago
Does anyone else feel that a site called &quot;You Might Not Need Javascript&quot;, probably shouldn&#x27;t use Javascript?
评论 #12691192 未加载
评论 #12691172 未加载
评论 #12692826 未加载
评论 #12691548 未加载
评论 #12691690 未加载
评论 #12691222 未加载
评论 #12691179 未加载
评论 #12692543 未加载
评论 #12691146 未加载
评论 #12691197 未加载
Semiapiesover 8 years ago
You <i>might</i> not, but you probably do.<p>The validation examples and input types are a case in point. Even on browsers where they work, the alerts can&#x27;t be styled and the behaviors can&#x27;t be controlled.
评论 #12691664 未加载
评论 #12691286 未加载
评论 #12691351 未加载
评论 #12694521 未加载
评论 #12691379 未加载
inianover 8 years ago
The you don&#x27;t need jQuery website had a concrete use case - you need not include an entire library into your website for some simple tasks which makes your website faster.<p>Though, this site is cool in showing the power of CSS, I am not sure if there is any specific advantage of using CSS over JS to design tabs, sliders, etc. Just use the best tool for the job!
评论 #12691502 未加载
评论 #12691731 未加载
评论 #12691693 未加载
Shanea93over 8 years ago
It&#x27;s sad that this site uses SCSS for displaying the rules, I&#x27;m using it in production and fully understand it, but it&#x27;s needlessly abstracting the rules for the sake of a few extra words in each declaration.<p>That aside, these are some pretty cool examples. Are there ways of doing this with CSS which doesn&#x27;t screw with my browser back button?
评论 #12691240 未加载
评论 #12691220 未加载
评论 #12691067 未加载
评论 #12691163 未加载
Jazcashover 8 years ago
Some of these are ok, but others are just misusing features for their intended purpose. An input gaining focus is not the same as a click event. Using the :checked peudoselector to keep client-side state is not an alternative to using JS.<p>Using HTML&#x2F;CSS hackery where you should be using JS instead creates an anti-SEO, non-semantic mess that causes headaches for others to work on and nightmares for anybody needing to extend or modify functionality.<p>Don&#x27;t get me wrong, I love pure CSS solutions and try to use them as much as possible where it makes sense. But sometimes, it definitely doesn&#x27;t make sense. JS isn&#x27;t something users or developers should be scared of anymore, it&#x27;s much better supported and much less intrusive than it used to be.
bshimminover 8 years ago
There is some useful stuff to learn from here, undeniably, but many of these are a bit useless when you compare them with what you would actually typically need on a real site. Yes, the &quot;image slider&quot; is vaguely functional, but really most of the time you will want a lot more control than just the CSS animations allow; similarly, yes, the form validation is a starting point, but normally you would want to customise the error messages and generally fiddle around with it a lot more; I&#x27;m not really sure the modal is fit for purpose beyond the most basic use case... etc.<p>It&#x27;s fun to see what you can partially achieve without JavaScript, but there is no shame in using JavaScript sensibly to enhance the usefulness of a web site.
评论 #12691796 未加载
评论 #12691452 未加载
zevebover 8 years ago
So, we&#x27;re all familiar with the fact that imgur requires JavaScript in order to display more than the first few images in a gallery (the &#x27;view more&#x27; link executes JavaScript; there&#x27;s no way to page forward). That&#x27;s highly annoying, since HTML supports exactly this use case.<p>It&#x27;s understandable, though, because we are not imgur&#x27;s customers: its customers are advertisers, and if we have JavaScript disabled then imgur&#x27;s customers have less ability to violate our privacy. Thus, it&#x27;s in imgur&#x27;s best interest to encourage us to reduce our privacy &amp; security, so that its customers may have their way with our browsers. I can&#x27;t see that the imgur programmers would care about the fact that they can do amazing things with CSS.<p>But recently I&#x27;ve discovered that Target&#x27;s website simply refuses to display products without JavaScript. This is insane: Target are, presumably, in the business of selling things. They ought to want to display a picture of their item and provide me a link to buy it; that&#x27;s in their best interest. Building that sort of website is <i>easier</i> than building the sort of ecommerce site which cannot even display an image and a link without JavaScript. It should be in Target&#x27;s best interest to do the right thing.<p>But it <i>doesn&#x27;t</i>. Its programmers <i>ought</i> to be interested in a site like youmightnotneedjs.com, but <i>are</i> they? If they didn&#x27;t bother to build their website properly before, is this likely to encourage them now?
duck2over 8 years ago
The issue with CSS sliders is that they mess with the browser history.<p>I expect my back button to open the previous page, not to move an image slider.
评论 #12691042 未加载
Cub3over 8 years ago
Am surprised no one has pointed out how bad these examples are for accessibility, no pause&#x2F;play on the slider, hidden content that won&#x27;t be read by screen readers etc.<p>I like the idea of using CSS over Javascript where it makes sense but in a lot of these examples it feels hacky.
评论 #12696056 未加载
d3ckardover 8 years ago
Since half the examples do not work on Safari, I believe the title is a bit misleading.
评论 #12691150 未加载
评论 #12691213 未加载
maxharrisover 8 years ago
If you use React and inline styles, you might not need HTML and CSS: <a href="https:&#x2F;&#x2F;vimeo.com&#x2F;116209150" rel="nofollow">https:&#x2F;&#x2F;vimeo.com&#x2F;116209150</a><p>Also, if you want the benefits of inline styles, but need media queries and the like, check out Radium: npm.im&#x2F;radium
评论 #12692272 未加载
mschuster91over 8 years ago
The biggest pain point with using :target is that location.hash, which powers it, is a single global state variable - which means you can&#x27;t nest tabs inside tabs, for example.<p>The slider has the problem that it cannot dynamically size with the container width, and the amount of slider elements has to be known at compiletime (width: n * 100%).<p>File upload has the nastiness that you can not really independently style the inputbox with the filename and the button. Chrome has input[type=&quot;file&quot;]::-webkit-file-upload-button, but I am not aware of a Firefox&#x2F;IE solution. Also, you cannot combine the input[type=&quot;file&quot;]::-webkit-file-upload-button with a general button selector in the same CSS rule, because Firefox doesn&#x27;t know the ::-webkit-file-upload-button and discards the whole rule as invalid - you have to double declarate your button styles if you want uniform button look in Chrome. And, even on Chrome, you cannot visually separate the inputbox from the button (e.g. I have a 2-col layout, 320px&#x2F;col and 16px margin, and I only can mess around with width, padding and margin instead of a clean separation).<p>To the people who whine about SASS: you can ALWAYS write the resulting CSS by hand, it just takes a boatload of manual typing.
TTProgramsover 8 years ago
Wow at the color picker. Funny that chrome seems to use my windows system color picker.
评论 #12691062 未加载
评论 #12691064 未加载
评论 #12694537 未加载
评论 #12691418 未加载
boubiyeahover 8 years ago
You might also not need CSS.<p>Doesn&#x27;t mean you should bruteforce everything with just one tech. CSS is hard to maintain.
Wintamuteover 8 years ago
Yuck. I&#x27;d take a simple well crafted and maintainable JS solution over an opinionated CSS preprocessor any day of the week.<p>Preprocessors do nothing but splinter the CSS scene by layering odd syntax over an already creaking&#x2F;complex CSS spec. Got nothing against compiling CSS in general - postprocessing features related to current and future CSS specs with PostCSS is a great idea. But dividing the community&#x27;s attention between multiple competing preprocessors while it should have been concentrating on the spec is the worst thing to have ever happened to CSS.<p>Great things happened to JS when people got behind tools that pushed the language forward while keeping the current and future spec in mind (ES6&#x2F;Babel). Shame CSS took an alternative approach imo.
jiiamover 8 years ago
Funny that I had to activate javascript in order to see the previews, so, although you don&#x27;t need JS in real life, you need it to convince people to stop using it.<p>Kinda like when Dante wrote in Latin about the utility of the Italian language.
k__over 8 years ago
A few days ago a saw a talk about CSS animations with RxJS [0] and the gist about CSS only stuff was something like: &quot;Yes, you can do much with CSS only, but it gets ugly fast.&quot;<p>Often you&#x27;re better of to do a mix of both, because some things that are very complicated in CSS are two-liners in JavaScript.<p>[0] <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=lTCukb6Zn3g" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=lTCukb6Zn3g</a>
评论 #12691250 未加载
aargh_aarghover 8 years ago
The site would benefit from displaying browser versions where each of those features is supported à la caniuse.com
Yuioupover 8 years ago
CSS is great, and by all means use it, while also being aware that you can build so many functional UI components without the additional dependancy.<p>Maybe you can include a few lines of utility code, or a mixin, and forgo the requirement. If you&#x27;re only targeting more modern browsers, you might not need anything more than what the browser ships with.<p>This site is fully copied from youmightnotneedcss.com, an excellent resource for vanilla CSS created by @somebody and @somebodyelse. But this time, we take a look at the power of modern native HTML and g as well as some of the syntactic sugar of DuJour. Because, you might not need scripts for that task at all! (Note: these methods can all be accessible, but the demos may not be. Please take a moment to test these before using in production)
carsongrossover 8 years ago
You might not need (to write any) Javascript, but you might <i>still</i> want modern UX with some AJAX.<p>I have some good news: <a href="http:&#x2F;&#x2F;intercoolerjs.org" rel="nofollow">http:&#x2F;&#x2F;intercoolerjs.org</a><p>You can add AJAX to your application without writing any javascript code, and you&#x27;ll get to use REST (with real, honest to God HATEOAS) without even thinking about it:<p><a href="http:&#x2F;&#x2F;intercoolerjs.org&#x2F;2016&#x2F;01&#x2F;18&#x2F;rescuing-rest.html" rel="nofollow">http:&#x2F;&#x2F;intercoolerjs.org&#x2F;2016&#x2F;01&#x2F;18&#x2F;rescuing-rest.html</a><p><a href="http:&#x2F;&#x2F;intercoolerjs.org&#x2F;2016&#x2F;05&#x2F;08&#x2F;hatoeas-is-for-humans.html" rel="nofollow">http:&#x2F;&#x2F;intercoolerjs.org&#x2F;2016&#x2F;05&#x2F;08&#x2F;hatoeas-is-for-humans.ht...</a>
kelseydhover 8 years ago
What are the performance implications of using CSS animations versus Javascript? Say, if you were trying to make an application where page animations need to be extremely fast, like under 2ms for an experiment or test.
评论 #12691378 未加载
评论 #12691376 未加载
etienn3over 8 years ago
CSS for behaviour = un-scalable non-x-platform big ball of crap<p>I understand why people try so hard to do without JS, but if you want to implement certain UI features, you&#x27;re SOL. Either give up on them, or embrace the pain.
denzellover 8 years ago
Or, you could use JavaScript and do something in 30 seconds rather than fiddling with CSS.<p>Why do people try so hard not to use tools that make their life easier?<p>You might not need a car - you can walk. But it makes life easier and it just works!
评论 #12691169 未加载
franzeover 8 years ago
Another point of view: an exceptional article by Jenn Schiffer &quot;A Call For Web Developers To Deprecate Their CSS&quot; <a href="https:&#x2F;&#x2F;medium.com&#x2F;cool-code-pal&#x2F;a-call-for-web-developers-to-deprecate-their-css-1f6430781393" rel="nofollow">https:&#x2F;&#x2F;medium.com&#x2F;cool-code-pal&#x2F;a-call-for-web-developers-t...</a> - HN Submit here <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=12691081" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=12691081</a>
评论 #12691103 未加载
评论 #12691589 未加载
dralexmvover 8 years ago
One thing I have taken issue with a lot of these different CSS &quot;component&quot; implementations, is the lack of examples on how one would write a good testing suite for these. My first reaction looking at these is not &quot;wow&quot;, but more &quot;how can I test this?&quot;<p>I would honestly be interested in hearing from some people here about how you would go about writing a proper test for these examples. And if the answer is &quot;webdriver screenshotting&quot;, I might just shake my head a bit.
edemover 8 years ago
&gt; JavaScript is great<p>I&#x27;ve never heard somebody say that. Can you elaborate?
评论 #12691560 未加载
ameliusover 8 years ago
The problem with using CSS for animations is that if the UX designers make a minor change to the spec, you might be forced to rip out the whole thing and redo it in JavaScript.
johnhenryover 8 years ago
I thew this together a while back if anyone&#x27;s interested: <a href="https:&#x2F;&#x2F;github.com&#x2F;johnhenry&#x2F;funwithoutjavascript" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;johnhenry&#x2F;funwithoutjavascript</a>
partycoderover 8 years ago
If you learn JavaScript, you would be learning an imperative language that shares many features with other languages, and you would be, as a resource, more flexible than if you just use CSS for everything.
bjnover 8 years ago
JavaScript is overused today, even for stupidest things. If needs to be done in JS, you&#x27;ll see God knows how many frameworks included. This idea reminded me of: youmightnotneedjquery.com
评论 #12695201 未加载
milkmirukuover 8 years ago
I would like to see more sites that use an uppercase title making it so via CSS so I can copy&#x2F;paste that without having to copy from the source &lt;title&gt; or be lazy and rewrite.
sundarurfriendover 8 years ago
Many of these make sense, but a few (for eg. &#x27;View Switcher&#x27;) end up obscuring the logic of what&#x27;s happening, and are probably better off done in JS.
评论 #12691259 未加载
minusSevenover 8 years ago
These examples are all good but I doubt whether you can really avoid javascript. In reality it&#x27;s more like you can&#x27;t avoid javascript if you wanted too.
Rafertover 8 years ago
Neat stuff. One small issue: the lightbox re-opens when I&#x27;m using the back button on my mouse (using Chrome), not sure if that&#x27;s fixable or not?
truth_sentinellover 8 years ago
IMHO unless your site is just showing static content, like a flier or something like that, not using JS will plunge your UX and overall productivity.
superkuhover 8 years ago
It&#x27;s funny that all the examples previews use CodePen and,<p>&gt;Codepen requires JavaScript to render the code and preview areas in this view.
dsegoover 8 years ago
These don&#x27;t work in Safari 10:<p>- The modal dialog example<p>- Color picker<p>- Form validation
评论 #12691397 未加载
drikerfover 8 years ago
Well done :)! Saved for future reference.
thomasahleover 8 years ago
The form validation is really cool!<p>But why oh why does it not validate before I press submit? Is that a Chrome specific thing?
评论 #12691415 未加载
luca_ingover 8 years ago
Does anyone else find it hilarious that this site doesn&#x27;t work without Javascript?
rebolekover 8 years ago
I might not, but I need for this page. Otherwise it would work with NoScript.
jiyinyiyongover 8 years ago
Uninstall all JavaScript engines from you browser to prove that!
dretaover 8 years ago
Best of luck making this work across browsers. And even more luck to anybody who uses this, and then has to come back 6 months later to change something.
eliover 8 years ago
But I need my site to work in IE9 too.
joshmnover 8 years ago
My very wide-cast idea is this: The last 5 years we&#x27;ve rid ourselves of flash (for the most part) and replaced it with javascript.
randomsofrover 8 years ago
Coming up next: You might not need SCSS.
chowardover 8 years ago
You might not need JavaScript*<p>* If you hate your users
notgoodover 8 years ago
You might nod near internet, heck, you many not need staying alive, but here we are.<p>Seriously, after some minimum complexity the ability to create functions and loops its extremely important. As in you don&#x27;t need a spoon and a knife to feed yourself, but it sure fucking helps.
评论 #12691421 未加载
评论 #12691386 未加载
justinlardinoisover 8 years ago
A lot of &quot;you don&#x27;t need Javascript&quot; articles show a bunch of CSS tricks that look flashy and cool but in reality are brittle, limited, and hard to maintain. There&#x27;s a fair bit of that here, but props for also pointing out some of the new HTML5 features that may have slipped under people&#x27;s radars. I was aware of the form validation and I think it&#x27;s a godsend, but I had no idea there&#x27;s a native color picker now too.
dcw303over 8 years ago
The site makes no claims as such, but it undermines its own credibility if it uses .js files.<p>Surely they could have figured a way to do without them.
评论 #12691026 未加载
评论 #12691702 未加载
评论 #12691265 未加载
评论 #12691130 未加载