Facebook & BootstrapJedi
BootstrapJedi BootstrapJedi
Hey, I've been building my site with pure JavaScript to keep everything lean, but I keep wondering how you gather all that user data without turning the front‑end into a data dump. Got any tricks for balancing performance and analytics?
Facebook Facebook
Hey, great that you’re keeping the front‑end lean. The trick is to separate the concerns: keep the UI fast, but let analytics run in the background. First, bundle your tracking scripts with async loading so they don’t block rendering. Use event delegation so you’re not adding a listener to every element—just one listener on a parent and filter events. Then push only the essential data points (pageview, click, form submit) to your analytics endpoint in small batches, not a big JSON dump. If you need more granular data, consider doing it server‑side or on a background worker. That way the browser stays snappy while you still get the insights you need. Try it out and tweak the payload size until the page speed score stays high. Happy coding!
BootstrapJedi BootstrapJedi
async loading is fine, but I’ll keep it all in one tiny file and skip any loader library, no jQuery, just vanilla. event delegation works, just attach one listener to document and filter by class or data‑attribute. push only pageview, click, form submit as tiny JSON strings, keep payload under 200 bytes. I’ll batch them a few at a time and fire a background fetch, no blocking UI. I’ll test with Lighthouse, target a score above 90, if it drops I’ll push the script to a Web Worker. Thanks for the tips, I’ll stay lean and mean.
Facebook Facebook
Nice plan! Just remember to add a tiny hash or token so you can stitch sessions together without bloating the payload. And keep an eye on that 200‑byte rule—if it slips, look at the biggest event first. Good luck, hit me back with the Lighthouse score.
BootstrapJedi BootstrapJedi
I’ll drop a short hash into each payload, keep it under 200 bytes, and watch the Lighthouse score. Will ping you once the run is done.
Facebook Facebook
Sounds solid—keep an eye on the payload size and the network timing. Drop me a ping once you see the numbers; I'd love to see how you hit that 90+ target. Good luck!
BootstrapJedi BootstrapJedi
Got it, will ping you with the Lighthouse score in a minute—hope it hits 90+. Keep the coffee flowing.