Hacker News new | ask | show | jobs
by johnisgood 1545 days ago
Phoenix seems quite bloated. Is there any way to make it work without JavaScript, or do I have to rely on it? I really wanted a web framework where I can have routers, templates, sessions, and the usual stuff and no JavaScript, only if I write it myself into the template. :(
2 comments

There’s no JavaScript unless you write it into the template. If you want to use LiveView that needs JavaScript but plain old templates do not.

As for bloat I don’t really agree but I can see how it might appear that way. Phoenix is actually not monolithic, it is sort of just a set of conventions and macros (batteries) that make using Plug and Ecto and some other libraries together more cohesive and more like programming in Rails. If you don’t like that approach you can also just use Plug and Plug.Router directly, which is more of a microframework feel like Flask or Sinatra.

Got any resources for simple usages of Phoenix? Most of them are all about LiveView and a lot of stuff that uses JavaScript.

> There’s no JavaScript unless you write it into the template.

I want this. How do I achieve this? "mix phx.new" is not it, as there are JavaScript files in "assets/", for example.

You pass the `--no-assets` flag when using `mix phx.new`[1]

Also ime, there's not many good blog posts or guides around Phoenix that I've seen. The sort of de facto resource would be the Programming Phoenix book. It's well worth the $25 considering the amount of effort Chris and co. seems to have put into it.

[1]https://hexdocs.pm/phoenix/Mix.Tasks.Phx.New.html

Thank you! Will give it a go. :)
`mix phx.new foo --no-live` does that. LiveView is completely optional. Node/npm has been completely replaced by esbuild and even that is optional if you want to rip it out and handle assets another way.
Yeah, I suppose that is why I thought it required JavaScript (the book instructed me to type --live). I was following the instructions of some books and there was JavaScript such as utils.js and whatnot.

I typed what you told me, but it does have "foo/assets/vendor/topbar.js" and "foo/assets/js/app.js". Not sure what those are though or if they are a necessity. It ends up being "deps/phoenix_html/priv/static/phoenix_html.js" on localhost:4000. Any ideas as to how to COMPLETELY avoid JavaScript? Are there any sources for that perhaps?

https://hexdocs.pm/phoenix/Mix.Tasks.Phx.New.html

I think you want the --no-assets option.