Hacker News new | ask | show | jobs
by th5 1632 days ago
I prefer laravel as well but it’s definitely not as snappy as an spa since I have to load a full page of html at each click. What are you doing differently that I should be doing?

Currently, I’m doing a hybrid sometimes where I’ll have jquery do a call inside the page when I want one particular area to be fast.

6 comments

Check out htmx. I use it for thing like table pagination.

Server side I check for htmx headers, and if so omit headers/footers are just return the body. htmx then handles the html swap and boom, you’ve just turned the page without reloading the whole page.

Simple and straightforward. I also use a plugin to preload the responses on mouseover in some cases for even more snapiness.

KISS. Keep the HTML minimal and the full page reload is often just as fast as an AJAX call. For the parts that need to be realtime/interactive I use Livewire. Livewire is annoying to work with sometimes, and the author got carried away with that whole AlpineJS nonsense (reinventing the whole problem), and Livewire is still immature, but the basics work well (just keep your Livewire components extremely simple and it works great).
Yeah, I cant count how many times I have seen SPAs have tons of calls to an endpoint that passes back huge amount of data when the client needed a single property from the response. This can get artificially bad in large companies that require devs to onboard each endpoint through an API exchange/gateway...because they avoid creating new endpoints.
Keep your markup lean, serve styles separately so they can be cached.
Take a look at the tall stack. It abstracts away the js that does partial page updates.

https://tallstack.dev/

How long does it take your server to render the page? That would directly translate to client-facing latency. You want that response time to be as low as possible, definitely under 100ms.
+1

I find Laravel + Unpoly a great combination.