drab icon indicating copy to clipboard operation
drab copied to clipboard

RFD: shall we make Drab JS static?

Open grych opened this issue 6 years ago • 2 comments

Now Drab injects its javascript directly into the page. This is why:

  1. Drab’s JS are dynamic (EEx), they depends on the configuration: for example they injects only the parts of used Drab Modules, so if you don’t want to use Drab.Live, it does not inject that part of javascript. Also, there are configuration options which changes the generation of the JS part.

  2. The JS generation function (Drab.Client.run/2) passes some information from conn to the client, for example - the controller name, in the token, which is checked on each execution of the event handler.

  3. Personally, I find npm and friends a nightmare.

I could extract all Drab JS and put it as an npm package, changing Drab.Client.run/2 to pass all the configuration options and modules to use. I could even split it into individual packages, so you could decide if you want Drab.Live or not.

Is it worth the effort?

grych avatar May 29 '18 10:05 grych

KISS, imho

guidotripaldi avatar May 29 '18 17:05 guidotripaldi

Note: https://elixirforum.com/t/drab-remote-controlled-frontend-framework-for-phoenix/3277/383?u=grych

grych avatar Jul 20 '18 16:07 grych