当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- axios学习笔记(二):轻松弄懂XHR的使用及如何封装简易axios
- 前端工程师需要懂的前端面试题(c s s方面)总结(二)
- [event center azure event hub] interpretation of error information found in event hub logs
- 一篇文章教会你使用HTML5 SVG 标签
- Jetcache buried some of the operation, you can't accept it
- ES6学习笔记(四):教你轻松搞懂ES6的新增语法
- I'm afraid that the spread sequence calculation of arbitrage strategy is not as simple as you think
- ES6学习笔记(二):教你玩转类的继承和类的对象
- 每个前端工程师都应该懂的前端性能优化总结:
- Python基础变量类型——List浅析
猜你喜欢
比特币一度突破14000美元,即将面临美国大选考验
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
合约交易系统开发|智能合约交易平台搭建
I'm afraid that the spread sequence calculation of arbitrage strategy is not as simple as you think
一篇文章带你了解CSS对齐方式
Summary of common algorithms of binary tree
Arrangement of basic knowledge points
Python download module to accelerate the implementation of recording
IPFS/Filecoin合法性:保护个人隐私不被泄露
随机推荐
Natural language processing - wrong word recognition (based on Python) kenlm, pycorrector
ES6学习笔记(四):教你轻松搞懂ES6的新增语法
From zero learning artificial intelligence, open the road of career planning!
2019年的一个小目标,成为csdn的博客专家,纪念一下
H5 makes its own video player (JS Part 2)
Solve the problem of database insert data garbled in PL / SQL developer
DRF JWT authentication module and self customization
Summary of common algorithms of binary tree
ES6学习笔记(五):轻松了解ES6的内置扩展对象
In order to save money, I learned PHP in one day!
一篇文章带你了解HTML表格及其主要属性介绍
axios学习笔记(二):轻松弄懂XHR的使用及如何封装简易axios
Introduction to quantitative investment and Trading (Python introduction to financial analysis)
Natural language processing - BM25 commonly used in search
Mongodb (from 0 to 1), 11 days mongodb primary to intermediate advanced secret
中小微企业选择共享办公室怎么样?
It is really necessary to build a distributed ID generation service
Recommendation system based on deep learning
Discussion on the development practice of aspnetcore, a cross platform framework
How to customize sorting for pandas dataframe