15 ms·
>Or consider not using a framework at all. For websites that primarily display content, it’s more efficient and cost-effective to just send some server-rendered
by superkuh 8y ago
>Or consider not using a framework at all. For websites that primarily display content, it’s more efficient and cost-effective to just send some server-rendered HTML down the wire. If there are areas of your website that require interactivity, you can always use JavaScript to build those specific parts.
This should be the takeaway from the article. There's absolutely no need for javascript on most websites that use javascript. I understand if you're forced into it by the time and economic contingencies of your work but if you bring JS frameworks home to your personal sites you're doing it wrong.
- StreamBright 8y agoExactly. I avoid JS as much as possible. Unfortunately most of web developers want to develop SPAs regardless of the actual need of the projects.
- snaky 8y agoSPA building experience, coupled with popular JS frameworks, sells usually better than the skills of carefully engineering solution for the task.
- maxxxxx 8y agoResume driven development works. Unfortunately.
- gedy 8y agoThese "carefully engineered solutions" typically aren't - and instead random js bolt-ons to whatever server side language. UI state is smeared across layers, and ability to test, share and modularize suffers. SPAs usually are better engineered UIs than the alternatives.
- malvosenior 8y agoThe backend has to handle all of the scale. That's where the real difficult engineering comes in and if you're using JS there, you're going to pay a huge price. It doesn't seem like many front-end JS developers understand that pulling data from different places isn't actually a hard problem but instead correctly storing and managing that data at scale is where the actual engineering happens.
- dancek 8y agoDo you have data to back that up, or are you speaking from personal experience? I know how it can go wrong, but SPAs can become a mess too. I had one project where we built a very beautiful, modern site that had about 50 lines of js in total. Of course your page-change times are going to be around 0.5s with an MPA, but SPAs are often slower than that anyway.
- fold_left 8y agoI don't know but with a service worker you could possibly reduce that 0.5 in your MPA further by caching likely next pages ahead of time.
- gedy 8y agoYes, mainly personal experience. SPAs can definitely be a mess too. Mostly calling out that managing state in one place makes unit testing easier, which usually results in a better quality codebase
- dmitrygr 8y agoAs opposed to spas that take forty seconds to load on a 48-core machine with a gigabit link? Yeah...
- sebazzz 8y agoState management is hard. That is the core issue. Note you can still use an MPA and have a dynamic UI using React/Knockout/whatever. It is just usually not done that way and most go full SPA.
- StillBored 8y agoWell in a way it makes sense. Its like learning any other technology stack. The core stack may not be the best fit, but its considered a better bet to hire someone with experience in the target language/stack because the learning curve is reduced. AKA, a developer that knows the same framework your app uses, only has to learn about your specific application rather than all the background libraries/etc your using. Its the same reason for preferring a C programmer for a C position over a ruby programmer (or flip it). Sure the ruby programmer might be awesome and after a couple years more productive, but in the meantime they will be making a bunch of newbie C mistakes, and generally bootstrapping slower. This is part of the reason i'm in favor of generally reducing the number of languages/frameworks in general use. Its better for everyone if we all agree on some simple baselines even if they may not be the most optimum for any given problem. The efficiencies of repeatedly avoiding a bunch of rookie mistakes (and then having to debug/fix/test them for the next few years) is well worth it in the long run.
- hahamrfunnyguy 8y agoI prefer the MPA (multi-page application) approach for most projects. If interactivty is needed, I use REST services and a data-binding framework on the front end.
- thex10 8y agoThis is the first time I've seen the "MPA" phrase used like this, but I think this is my preferred approach too.
- nobody271 8y agoSame, as a user I like the feel of going to a separate page.
- jessaustin 8y agoCan you recommend any such frameworks?
- the_gastropod 8y agoStimulus is is a pretty good example of a simple JS framework that binds via data attributes. It, coupled with Turbolinks or Pjax, should let you do nearly anything you'd typically use a more popular front-end framework for, for much cheaper. Check it out: https://stimulusjs.org/ https://stimulusjs.org/
- jessaustin 8y agoThanks, that looks really cool.
- flukus 8y agoKnockoutjs works well for this, have heard vuejs is similar but haven't tried it. That's for highly interactive pages of course, for simple pages that just need some regex validation or something, no framework is the best framework.
- 8y ago
- sotojuan 8y agoSaying you have SPA experience with the latest frameworks makes it easier to get a job.
- StreamBright 8y agoI understand. I just do not accept the incidental complexity and performance tradeoffs these SPAs mean. I have built several of them over the last couple of years but still like to avoid them as much as possible.
- deleted 8y ago[deleted]
- mattferderer 8y agoI find JavaScript (especially React) to be an awesome template framework for non-SPA websites. I've used it in situations where I'm just creating server side template components. The JavaScript ecosystem can be extremely enjoyable for fast development.
- deleted 8y ago[deleted]
- zeveb 8y agoAmusingly enough, his charts & images don’t display without JavaScript. Are they interactive, or is he himself using JavaScript when a simple img tag would suffice?
- xrisk 8y agoIt's probably because his blog is hosted on Medium.
- hu3 8y agoBlame Medium. Why do people even use this pile of garbage? * Slow * Bloated * No images if you block cookies or js * Paywalled. Asks for $5 membership every other day. Requiring deleting cookies to read articles * Probably tracks the living shit out of visitors * Somehow needs a ton of js to render a blog article * Frequent divs in the middle of the screen asking to create an account And they don't even produce content. It's all created by users. I see business opportunity here.
- Drdrdrq 8y ago> I see business opportunity here. Genuinly curious: do you see one without the annoying aspects you described? How would you monetize it?
- hu3 8y agoAdmittedly, I don't know of another blog platform without ads. But I haven't taken time to search either. > How would you monetize it I wouldn't. Medium solves a non-problem. It only exists because VC funds have this tendency of pouring money over anything that resembles business. However, Medium isn't too big to fail and I suspect its grace period is long past and now business decisions are mostly driven by shareholders seeking a favorable exit strategy. [1] [1] https://marketingland.com/medium-will-eliminate-promoted-stories-ad-product-following-layoffs-202566 https://marketingland.com/medium-will-eliminate-promoted-sto... But if I really had to come up with a way to monetize Medium, I'd take a look at Wikipedia business model.
- nine_k 8y agoIf your site can render without javascript, it can render without ads. Some sites explicitly don't want that, unfortunately.
- was_boring 8y agoWhy is JavaScript required for ads?
- reaperducer 8y agoIt's not. It's required for tracking. I run several websites where advertisers pay to be on the website so that their brand can be associated with the content, and get viewed — just like a billboard or a TV commercial. None of them have Javascript. They're just plain images and links.
- samfisher83 8y agoYou don't need javascript for tracking. You could just use an invisible pixel.
- pritambaral 8y agoSome advertisers don't like to trust hits if they can't verify the hit came from a real, live browser. Like the difference between the original recaptcha (read the letters in this image) and the new ones (mouse, keyboard, and browser behaviour looks like a human browsing on a real browser).
- giobox 8y agoIn an absolute technical sense of course it isn’t, but virtually all the major players in web ads (Google Adsense etc) typically use JS to ship ads/tracking to your page.
- nine_k 8y agoIt is not strictly required, but most ad networks want to know about you as much as possible, from display resolution to browsing history (if they can). This requires JS. Also, a lot of ad content is "rich", animated, etc, also scripted. In 1990s and early 2000s ads were mostly just images ("banners") served by an ad network, or even text links, without any scripting.
- StillBored 8y agoIts not just that, but due to the difficulties of getting CSS to do what you want, it seems standard practice now has everyone using JS for basic layout/update tasks. Back when I was doing a lot of web development getting something sitting in the right place with CSS frequently took me much longer than just writing a bit of JS to adjust the size/position, but the results with CSS were much faster to respond.
- the_duke 8y agoThe big challenge for this are different screen layouts. Mobile + desktop support is basically a hard requirement. A tablet-optimized version is nice to have. This gets very hard to do well with just CSS.
- superkuh 8y agoOr you could just not care about mobile's inadequacies. That's one of the joys of making personal websites. You get to do what you want not what's required to make the most money.
- subbz 8y agoNot true. Check out CSS media queries.
- pasta 8y agoAnd grid for repositioning blocks
- H1Supreme 8y agoI'll second this. FlexBox + CSS Grid with the appropriate media queries can handle just about every layout configuration you can throw at it.
- Beldin 8y agoWhen i checked those, searching uncovered statements that most smart phones are lying. Which would explain why my tests never worked in my phone. Maybe I've been led astray, but from what i gathered about a year ago, media queries cannot distinguish between desktop and phone, you need JS to do this. Please tell me I'm wrong about that (at least, if you give me a hint on how to do it).
- golergka 8y agoWhen I browse the web, I disable JS by default. In overwhelming majority of the cases, it makes everything so much faster and nicer.
- siquick 8y agoI don't understand why this point is brought up on HN everytime there's a discussion about JS. The behaviour of disabling Javascript represents an almost non-existent subset of web users and developers have more pressings things to think about.
- sircastor 8y agoI agree. I appreciate that you _can_ disable JavaScript, but I don't really think of it as a realistic option for using the web in 2018, and certainly not for the average user wanting to do average things.
- Drdrdrq 8y agoIt actually is a completely viable option in 2018 for advanced user wanting to do average things (with uMatrix for example), and it is a nice experience. Agree about average users though.
- deleted 8y ago[deleted]
- AnIdiotOnTheNet 8y agoBut considering how horrifically bad things have gotten, maybe we should be making a concerted effort to make it realistic.
- ricardobeat 8y agoThere is no need to go raw if you can use a library like Preact (3KB) or HyperApp (1KB) and still get the majority of the benefits of using a modern component architecture.
- christophilus 8y agoThe problem I have is that my UIs generally end up with complex requirements. At first, it's just a standard CMS-like site with relatively static content. Then they want discussions. Then they want live discussions. Then they want the ability to highlight sections of the article and hang running side-conversations off of those... etc... Without using some kind of front-end framework, I end up organically evolving my own to tackle the increasing complexity of the UI. Now, I've got UI logic spread across two layers: my back-end (Rails or whatever) and in my front end (my hodgepodge JS), both of which need to dynamically render / update markup-- at which point I wish I'd just gone with an SPA framework in the first place.
- OtterCoder 8y agoSee, that's the point where I usually wish I hadn't used a framework. As your design gets more and more convoluted, the amount of switches, toggles, and special cases that you have to build into the widgets tends to balloon. Most current frameworks make that an exhausting exercise in state drilling, and it becomes hard to reason about how any given change in application state will affect the view.
- devwastaken 8y agoJavascript has specific client side features that servers cannot provide. Good luck doing google maps without JS.