Bundle size with Alpine.js #94
Replies: 6 comments 15 replies
-
Hello—Thanks for posting this! And you're very welcome—always very happy to hear people are finding _tw useful. I use Alpine.js for almost every site I build. To get the exact answer when added within _tw, I generated a new theme, added Alpine.js (and nothing else—no plugins), and then minified and gzipped that file. The result is 15,678 bytes, or roughly 16 KB. (Using Alpine.js doesn't need to be render blocking, and the file created by esbuild is placed in the footer by default, so the page will be displayed without the JavaScript file blocking it. I think 16 KB fits comfortably into most performance budgets, but I don't want to speak for everyone. In my experience, it ends up being smaller than or equal in size to a single weight / style of a web font, which seems like a very reasonable price to pay for what it provides. |
Beta Was this translation helpful? Give feedback.
-
Hi again :) Greg, thanks a lot for this kind of detailed answer! I found _tw super useful for custom WordPress projects and was curious just about build with Alpine.js (never used it with WP earlier). 16kb is great job and should deliver best results, I hope you will continue to maintain this awesome project :) |
Beta Was this translation helpful? Give feedback.
-
Hi again Greg, When typing my JS at javascript/script.js it doesn't work in my header file at template-parts/layout/header-content.php ? But when I type in using <script> tag, it's working well :/ Do you have any suggestion? thanks in advance |
Beta Was this translation helpful? Give feedback.
-
Hi Greg, sorry for late reply on this topic :/ Everything works well. I would like to know which bundler you are using for this theme? (webpack, parcel, vite) |
Beta Was this translation helpful? Give feedback.
-
Hi Greg, I was wondering about tailwind plugins like 'autoprefixer' and 'purgecss' for removing unused classes, does the theme have it already or we need to install them? Also with using Alpine in our projects, do we need to edit content array in tailwind.config.js for example like this? content: [ Thank you in advance! |
Beta Was this translation helpful? Give feedback.
-
I got it! Thank you for providing this part of Tailwind's documentation and fast support, now it's make sense to me. Sincerely, Nikola. |
Beta Was this translation helpful? Give feedback.
-
Hi Greg! Thanks for this awesome starter theme and things you are doing about! :)
I'm just curious about adding Alpine.js to my project with your theme, about it's size as a third-party dependency? Will it slow down loading time and general performance?
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions