当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- It's so embarrassing, fans broke ten thousand, used for a year!
- 6.5 request to view name translator (in-depth analysis of SSM and project practice)
- 一篇文章教会你使用Python网络爬虫下载酷狗音乐
- The road of C + + Learning: from introduction to mastery
- ES6学习笔记(四):教你轻松搞懂ES6的新增语法
- Python基础变量类型——List浅析
- The difference between gbdt and XGB, and the mathematical derivation of gradient descent method and Newton method
- Mac installation hanlp, and win installation and use
- Pattern matching: The gestalt approach一种序列的文本相似度方法
- Windows 10 tensorflow (2) regression analysis of principles, deep learning framework (gradient descent method to solve regression parameters)
猜你喜欢
ES6学习笔记(五):轻松了解ES6的内置扩展对象
有了这个神器,快速告别垃圾短信邮件
Word segmentation, naming subject recognition, part of speech and grammatical analysis in natural language processing
Flink的DataSource三部曲之一:直接API
vue-codemirror基本用法:实现搜索功能、代码折叠功能、获取编辑器值及时验证
一篇文章带你了解CSS3圆角知识
合约交易系统开发|智能合约交易平台搭建
In order to save money, I learned PHP in one day!
Arrangement of basic knowledge points
vue任意关系组件通信与跨组件监听状态 vue-communication
随机推荐
Advanced Vue component pattern (3)
[Xinge education] poor learning host computer series -- building step 7 Simulation Environment
6.2 handleradapter adapter processor (in-depth analysis of SSM and project practice)
Individual annual work summary and 2019 work plan (Internet)
What problems can clean architecture solve? - jbogard
vue-codemirror基本用法:实现搜索功能、代码折叠功能、获取编辑器值及时验证
ES6 essence:
中小微企业选择共享办公室怎么样?
Do not understand UML class diagram? Take a look at this edition of rural love class diagram, a learn!
Common algorithm interview has been out! Machine learning algorithm interview - KDnuggets
Analysis of query intention recognition
Process analysis of Python authentication mechanism based on JWT
零基础打造一款属于自己的网页搜索引擎
01. SSH Remote terminal and websocket of go language
6.6.1 localeresolver internationalization parser (1) (in-depth analysis of SSM and project practice)
I'm afraid that the spread sequence calculation of arbitrage strategy is not as simple as you think
use Asponse.Words Working with word templates
Interpretation of Cocos creator source code: engine start and main loop
The road of C + + Learning: from introduction to mastery
Analysis of etcd core mechanism