当前位置:网站首页>What if the front end doesn't use spa? - Hacker News
What if the front end doesn't use spa? - Hacker News
2020-11-06 01:33:00 【On jdon】
A piece of 《 If the front end doesn't use SPA What can I do ?》 Initiate a discussion , This article discusses in addition to React.js Other frameworks :Remix,RedwoodJS and Blitz.js.
With Remix For example , It reconnects data loading with routing , And then he made an amazing promise , That is, no client data will be extracted by default . These frameworks also consider state codes and caching strategies .RedwoodJS Use GraphQL and Prisma Automatically create Be similar to ORM The interface of .
It is worth mentioning that Turbolinks.Turbolinks 5 The goal is : Without any application collaboration , get SPA What's the minimum you need to experience ?
This is a very small one JavaScript library , It sits on top of existing server rendered applications , And use something like SPA Part of the page load instead of the full page load . No need to load pages from scratch , But use AJAX Loading page , Replace page content , And the client navigation updates your URL. Basically , It prevents the actual page conversion from “ flashing ”, And it saves all the other costs of fully loading the new page .Turbolinks It's from Ruby on Rails Project derived , But with Rails Well matched , But it's not needed .
In terms of the weight of improving the user experience ,Turbolinks It's an outstanding product : It brings minimal complexity and small size impact to a complex user experience .
The article also mentions the server-side state framework : The main competitors are Laravel Livewire(PHP),Stimulus Reflex( stay Ruby on Rails Use in ) and Phoenix LiveView( stay Phoenix Medium Elixir Use in ). These frameworks are exciting , And extremely rebellious , Because they are associated with “ front end + I don't know API layer ” The pattern is the opposite , And they wholeheartedly accept things that everyone wants to avoid : Variable state on the server .
Various opinions :
From my first contact with Angular since , I've always felt this problem . Unless you want to make a real interactive asynchronous application ( for example Google Docs or Facebook Chat), Otherwise, it will become more complex and fragile , And it doesn't actually do any good .
When SPA Become the norm , You even need to use React When building a static web page , Development efficiency is also getting lower and lower . I see the whole team trying to build simple applications , And wasted months of time , These teams used to develop on a proven server-side framework with just one or two developers in a few weeks . however , It's no longer in line with best practices and industry standards . Everything needs to be SPA, Microservices , Distributed database ,Kubernetes etc. . These components and layers need to be bonded together through trial and error .
I'm glad that common sense is becoming popular , More and more developers are beginning to realize that integrated end-to-end frameworks are very useful for many real-world application development scenarios .
Interestingly , I find that the opposite is true . I've been working on front-end code for more than ten years , But I've never done it faster than now , There is also less error code written . Is that because I've become a better developer ? Certainly. . But on the whole , I don't think it's ultimately the reason . I think it's the maturity of the technology . My development as a programmer is hardly linear , In the past 5 Years ago with me 5 The growth in this is not matched . Front end tools have never been better .
I Believe , structure Web The threshold for applications has been lowered , And more programmers than ever before . You may not be developing and javascript Aspect attempts to construct complex UI And application experts . therefore , You've chosen someone who doesn't have the necessary experience , And use a framework that's really easy to use , Put them into quite a lot depth ( front end ) Working in a paradigm , But they can get into trouble by abusing these complex issues .
Another factor is , because SPA It's stateful , So complexity will surge . A page doesn't refresh stateless pages every few seconds , Instead, it leads to errors raising their heads during the duration of the conversation . These inexperienced people are responsible for designing a code base that doesn't scale and doesn't become spaghetti . however , If the design is reasonable , These problems will be greatly eliminated .
I'm not advocating SPA It's the way to solve all problems . I think the whole industry is seriously abusing SPA, But it's not right SPA Their own complaints . It's the people who choose the wrong technology to solve the current problem .
The fundamental problem is not SPA The pattern is not good , It takes a lot of skill and effort to make the right SPA. obviously , Skills and time are scarce resources , The result is that most SPA It's all bullshit .
And jQuery Compared with the times , All of these component-based OTOH The framework undoubtedly brings us a better way to produce an interactive experience . This is fundamentally related to SPA Unrelated . You can use React / Vue / etc. The problem lies in , To mix ( Interaction ) Server rendered HTML, You now need to copy tags between the server language and the front-end framework . The solution is to use the same framework on the back end and the front end , And write components only once .
I'm using TALL Stack (Tailwind,Alpine.js,Laravel and Livewire) Build an application , And my productivity is incredible . There are very few build steps required ( according to .blade.php Classes used in files , compile Tailwind To reduce the size ). I like it very much CRUD, Image upload and other operations . At first I was suspicious of , But now I like this kind of construction Web How the application works . I don't know how scalable it is , But for a simple MVP, I never asked for a better stack .
I professionally wrote a complete SPA. We use React,Apollo,GraphQL,Webpack etc. .TALL The stack is full of fresh air . I couldn't even begin to explain my joy . Just happy .
Now? , I have to write about the infinite JS Code , Conflicting dependencies , Slow build time ,React Hook state management, etc .
When I talk to my colleagues about technology , They all seem to like it JS The tangle of developers , And willing to use any new framework released . I've been trying to get good old reliability SSR. Although it is often called “ weird ”, But I prefer old-fashioned technology .
I think I prefer a better developer experience and shorter production / Time to market , Instead of spending a few days trying to build a project and find strange quirks and problems , for example “ Server free modern Web Applications ” Such a complex mess .
I use Turbolinks + Stimulus The method has been a great success . There are two common patterns , for example , Delay loading content ( It's basically having URL Attribute <div>, You can AJAX Carry out excitation loading ), And it does tend to Rails Remote links to / The server javascript Response modes and small page updates .
With most React / SPA The code base ( You may send out the whole day in a whole day ) comparison , Still very productive , It's great to be able to complete a few pages of an application in a few hours .
about 2 Years ago , For the first time I was in the new Rails The application uses Turbolinks, But shocked by the impact - In terms of no page loading and overall speed , It's like SPA.
I firmly believe that this is the solution for most use cases , Combined with right React Component or Stimulus A combination of selective uses such as , In these cases, you need more complex UI Components .
版权声明
本文为[On jdon]所创,转载请带上原文链接,感谢
边栏推荐
- Custom function form of pychar shortcut key
- 一篇文章教会你使用Python网络爬虫下载酷狗音乐
- 6.5 request to view name translator (in-depth analysis of SSM and project practice)
- Network security engineer Demo: the original * * is to get your computer administrator rights! 【***】
- 一篇文章带你了解CSS 分页实例
- Word segmentation, naming subject recognition, part of speech and grammatical analysis in natural language processing
- 一篇文章带你了解CSS 渐变知识
- Did you blog today?
- Vite + TS quickly build vue3 project and introduce related features
- Discussion on the development practice of aspnetcore, a cross platform framework
猜你喜欢

仅用六种字符来完成Hello World,你能做到吗?

ES6学习笔记(二):教你玩转类的继承和类的对象

Summary of common algorithms of binary tree

一篇文章教会你使用Python网络爬虫下载酷狗音乐

If PPT is drawn like this, can the defense of work report be passed?

Wow, elasticsearch multi field weight sorting can play like this

前端基础牢记的一些操作-Github仓库管理

前端都应懂的入门基础-github基础

Python基础变量类型——List浅析

Free patent download tutorial (HowNet, Espacenet)
随机推荐
Common algorithm interview has been out! Machine learning algorithm interview - KDnuggets
git rebase的時候捅婁子了,怎麼辦?線上等……
The data of pandas was scrambled and the training machine and testing machine set were selected
Interpretation of Cocos creator source code: engine start and main loop
DRF JWT authentication module and self customization
Linked blocking Queue Analysis of blocking queue
Nodejs crawler captures ancient books and records, a total of 16000 pages, experience summary and project sharing
快速排序为什么这么快?
Summary of common algorithms of binary tree
带你学习ES5中新增的方法
零基础打造一款属于自己的网页搜索引擎
MeterSphere开发者手册
Process analysis of Python authentication mechanism based on JWT
百万年薪,国内工作6年的前辈想和你分享这四点
Introduction to quantitative investment and Trading (Python introduction to financial analysis)
Our best practices for writing react components
Architecture article collection
比特币一度突破14000美元,即将面临美国大选考验
The road of C + + Learning: from introduction to mastery
Analysis of etcd core mechanism