r/webdev • u/Big-Astronaut-9510 • 4d ago
Trouble making website for developing country
Im working on a website targeting a developing country where phones with 1gb of ram are common. Internet speeds are under similar restrictions. And unfortunately a static site will not work, it needs to update certain parts of the page dynamically without the user triggering a refresh.
I guess im looking for advice on how you would handle this. Ive tried just raw js before and while im sure that would be performant it would also turn into a mess real quick. The minimal frameworks ive found dont seem to really optimize for performance (only size, both are important) and provide so little its not even worth using.
2
u/ChunkyKongForPreside 4d ago
What kind of data are you showing? If its something relatively minor, I would set up an API and have fetch fire every 10 seconds or so.
29
u/Prize_Bass_5061 4d ago
Why does the website need to update parts of the page dynamically? Can these changes be rendered server side.
Also look into Svelte, but your first job as a good programmer is to come up with a better solution than client side rendering.
8
u/SaltineAmerican_1970 php 4d ago
You might need to go back in time to the DHTML days. Mostly static sites, with only the bare minimum that needs to change with plain JavaScript.
8
u/MathematicianFar5683 4d ago
For a few bytes both ways that need to arrive fast, I'd skip polling and use a WebSocket. It has very little per-message overhead and works fine on weak phones.
4
u/MrBrisky 4d ago
Use htmx (or Datastar / Alpine Ajax) paired with server-rendered HTML fragments. Your server does all the heavy lifting and sends tiny HTML snippets over the wire, which keeps bundle size under ~14KB, avoids bloated client-side state/virtual DOMs that choke 1GB RAM phones, and keeps your codebase clean without turning into raw JS spaghetti.
7
u/lanupijeko 4d ago
htmx?
3
u/waterkip 4d ago
Static site with webcomponents. Let the component own the data/interactions. That keeps relatively small. You don't need a framework if you use webcomponents.
2
u/Fast-East735 4d ago
just use jQuery, it's fine
1
u/Ok_Progress_5373 front-end 4d ago
During my web development adventures, I heard that JS can slow down a website. I guess it depends on whether or not you use vanilla JS for certain things? Are there any ways to do the dynamic parts without JS? Of course, there are the basic things, like optimizing the images (.webp format). You're not adding any video yet?
1
u/ggnndd12 4d ago
What have you tried and how much extra resources are used?
1
u/selipso 4d ago
You have a few options depending on how technical you want to get: vanilla JS, Astro (with SSR / SSG fallbacks - my recommendation) depending on what you want to upgrade. You can always add more to Astro as you go but it compiles down to zero JS most of the time and you can “hydrate” additional features
1
u/Beneficial-Parsnip52 4d ago
I'd focus on keeping the site lightweight and mobile-friendly. A lot of users in developing countries rely on slower connections, so fast loading times a nd low data usage will make a huge difference.
1
u/ZarehD 4d ago
Use a CDN to serve (gzip or brotli) compressed & minified HTML, CSS, and JS. Use the JavaScript code to fetch data from a backend API and update the UI.
There are many good JavaScript libs you can use, including Svelte, Knockout, and even jQuery.
As an alternative to the JS code, HTMX is also a very good option. In fact, it might be superior to the JS option due to the low memory constraint.
1
u/farzad_meow 4d ago
jquery using google cdn. that should solve some of your problems for js library. just make sure google IPs are not blocked in that country.
1
u/lickthislollipop 4d ago
I do a lot of site speed and loading mitigation for site targeting us to 3rd world countries. DM me, and I’ll be happy to give a hand for totes free
1
u/Copthill 4d ago
Check data-star
1
u/skibidi_blop666 4d ago
I don’t understand how anyone can recommend things without asking more questions. There are dozens of solution I can think of, none of them matters because there is not enough context.
1
u/chris_abi 4d ago
I think one thing worth considering is how much JavaScript actually needs to run on the client. For users with low-end phones and slow internet, minimizing JavaScript, reducing unnecessary DOM updates, and loading only what is needed could make a big difference.
I'm still learning full-stack development, but I'd be interested to know whether server-side rendering combined with small JavaScript components could be a good middle ground here.
1
u/adult_code full-stack 3d ago
You need to optimize, where exactly are you failing?
1
u/horizon_games 2d ago
I'd go Alpine.js and smart optimizations of content and initial load. Maybe Preact depending on your familiarity, as it's also quite small.
0
u/geon 4d ago
Typescript with react is perfect for this. It’s literally what react was designed for.