567 words long | 3 minute read
As someone who has historically used jQuery on all of their projects, I have in the last year begun testing more “up to date” tools. Throughout the years I have used a lot of different frameworks like Angular, Vue, etc. and never really settled on one that worked for me. The things I really care about in order of importance are:
I typically place importance on speed over all. The thing I liked about jQuery was that I could dump one line of code and have a bunch of useful commands immediately. All without needing to compile, set up a build, etc.
When I saw AlpineJS for the first time I saw it had a similar philosophy. I could just load a script via their CDN and immediately get a bunch of powerful features like data binding, manipulation, and even do some API calls. This has lead me to using it in my previous project and when I’m prototyping new things. If we take the list above it ticks a lot of the boxes with a caveat that there are sometimes some hacks things you have to do in order to make API/DRF calls to Python/Django but hey, hacky sometimes works.
Here’s why I’m continuing to use AlpineJS with Django for the time being.
Django has it’s own entire templating language that is pretty useful. AlpineJS can sit on top of Django and still be a ton of use. You can even pass it variables from the context which is really useful. It’s lightweight enough that you can kind of just plug it into any div you want but still powerful enough to listen for clicks, keystrokes, etc.
Because it’s plug and go I find I can prototype faster. For me, the hardest thing for a lot of projects is going from that 0 to 1 phase. If I’m messing around with a build pipeline, I’m more likely to get stuck, stop for a bit, and never pick the prototype back up.
Being able to load the script and hit the ground running is crucial for me. I find that I can get some really nice interactions with Alpine while not getting hung up on packages or a build.
Other people might disagree with this, but Alpine seems to have a ton of similarities to Vue. I feel really confident that I could upgrade to a more robust system later if need be. It might be a hassle having to translate my code over to something, but if I’m at the point where I’ve outgrown Alpine it’s probably a project that is successful and needing to upgrade will be a good problem to have.
Alpine is not the perfect solution by any means. It’s another imperfect tool I’m choosing to use as it checks the most boxes for what I typically like to develop in the early stages of my projects. If you use a more JS based stack then Vue or React will probably work just great! For me, I like only have to worry about PIP for the most part and upgrade my front end at a later date.
Aug. 13, 2017, 5 min read
May 12, 2022, 3 min read
May 19, 2022, 3 min read