Answer the question
In order to leave comments, you need to log in
Is it reasonable to use Angular 4 on a classic PHP site and not as a SPA?
Good day to all.
General situation:
Angular 4 does a great job with SPA applications, this is clearly understandable. But we have a very large site, where about 40% of the pages are promoted in search engines and are dependent on SEO, and the remaining 60% are service, such as a personal account and other similar things that are available only after authorization.
The entire site is based on a self-written PHP framework, so there is enough flexibility to implement crazy ideas, and jquery+knockout works on the front. SEO pages are rendered on the server, and service knockouts using ajax requests, accessing the API (there is a full API with everything you need). We have a lot of forms and various fields/selects that now work with ajax c API, they are on both pages.
What we want:
We want to unify the frontend and bring it to the same denominator, it is possible to get rid of jquery and knockout and replace them with Angular 4, as this will allow us to more conveniently manipulate the data coming in via api and display/modify/delete/create them.
Question:
How much is it reasonable to use Angular on a classic PHP site? After all, as I understand it, it is designed for the fact that within the SPA it takes a long time to load once, and then you can quickly use the application, but how will it be on a regular site? Will it not turn out that with each transition to a new page, we will reload the entire Angular for a long time?
And yes, knowing how Angular (a single interconnected system) works, I still hardly understand how it can be implemented on such a site, but I really want to)))
Answer the question
In order to leave comments, you need to log in
You yourself wrote everything correctly.
Unless you meant the pages that are now rendered on the server for search engines, transferring to Angular is nonsense (it makes no sense at all and through the ass in particular).
Those. what you have now on jQ + KO - you can rewrite it, but it is unlikely that it will give any gain except that it will become "stylishly fashionable for youth" .. and hemorrhoids ..
And by the way, if you still want to rewrite -modern, I would highly recommend throwing Anguryar out of the candidates, and first of all look at Vue.
Leave the site (as it is now) in regular PHP and separately load libraries for unified block handlers in native JS (without any JS libraries like jquery and the like).
As soon as a unified block is placed on the page (a unified form, or animation is needed, processing of input and sending data, etc.) - connect the required library (on the PHP side, which is the handler of this block) and dynamically "hook" the handler (processing class event logic for this block) to it when the page is initialized (on the client side).
Don't forget to enable static caching for the browser (headers returned by the server).
PS: No need to create difficulties where they can be avoided.
SEO is possible using server-side prerendering and Angular Universal .
And in terms of download speed - a fairly large site using Lazy Loading and Ahead Of Time loads quite quickly, in a second.
I advise you to try, perhaps you will be able to completely switch to SPA =)
Have a look at Vue.js I have the same situation. Angular is good as a spa, Vue can be perfectly interspersed with parts of a project and you will start using it in an evening
For such purposes, it is better to take React, you do not need to store a complex state on the front, but you just need a convenient VM library. Of course, you can take Angular, the core is not very healthy there, but still a lot of everything will remain unused.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question