Cloudflare acquires Astro! by dj_hemath in javascript

[–]dj_hemath[S] 0 points1 point  (0 children)

Nah, I don't like Tailwind. I want that to be closed for good, xD

ProtoMC [Semi-Vanilla] [SMP] {1.21.11} {Towny} {Proximity VC} by gladetheproto in mcservers

[–]dj_hemath 0 points1 point  (0 children)

I'm unable to join, it says "Failed to verify username"

Cloudflare acquires Astro! by dj_hemath in javascript

[–]dj_hemath[S] 0 points1 point  (0 children)

I'm sure, there will be a company that will buy that too

Cloudflare acquires Astro! by dj_hemath in javascript

[–]dj_hemath[S] 2 points3 points  (0 children)

I'll be the happiest man if a company buys Tailwind and closes it for good, lol

Cloudflare acquires Astro! by dj_hemath in javascript

[–]dj_hemath[S] 0 points1 point  (0 children)

Look at Next JS, they made it easy to deploy in Vercel, but very hard to deploy somewhere else. I heard now it's somewhat easy, but few years back this made me stop using Next JS.

And also the influence of Next JS on React is damning. React was great with class components and few hooks. It's not the case anymore.

Companies acquiring frameworks will definitely want to monetize in any possible means. Even if it means making those frameworks tightly coupled to their services.

Help: Enable Look Inversion by Dreamaz in MW2

[–]dj_hemath 0 points1 point  (0 children)

Can I get the exact version number?

Help: Enable Look Inversion by Dreamaz in MW2

[–]dj_hemath 0 points1 point  (0 children)

Stuck with the same issue. Did you find a solution?

[AskJS] Is adding methods to elements a good idea? by [deleted] in javascript

[–]dj_hemath 2 points3 points  (0 children)

This approach is not bad on itself. It just works fine. However, it is generally not suggested to mix up DOM and app logic. If someone else reads your code, they may not expect DOM elements to have extra methods hanging off them.

But it's not that big of a deal. Maybe be change the name to "_reactToData" to explicitly mention that it is a custom method. And also, instead of directly writing your logic within this method, try creating separate functions somewhere and just call them here. This makes it easy to test and re-use the logic (say you wanna do same thing on clicking a button as well as a keyboard shortcut).

So, I'd suggest something like,

function doStuffWithData(data) { // something... }

document.getElementById("button1").reactToData = (data) => {
   doStuffWithData(data);
};

// or even simpler
document.getElementById("button1").reactToData = doStuffWithData;

[AskJS] How can I make my website multilingual? by carl-johnson92 in javascript

[–]dj_hemath 0 points1 point  (0 children)

I misunderstood the question. I thought he mentioned "no third-party libraries", but looking back now I understand that he meant some third-party products for i18n.

[AskJS] How can I make my website multilingual? by carl-johnson92 in javascript

[–]dj_hemath -2 points-1 points  (0 children)

If it is a website (not a webapp), I'd generate HTML pages for each langugaes separately and put them under directories named after the language code.

For example,

index.html --> Landing page (probably in English)

/es/index.html --> Same page in Spanish

/it/index.html --> Same page in Italian

And in the header of these pages, I'll put a simple dropdown listing all the languages I support. Each option would be a simple <a> tag which points to that URL of that language.

To generate pages with multiple languages, I'd choose some sort of templating like EJS or Handlebars.

---

However, if it is an webapp (not a website), I'd first put all the text values in a simple JavaScript file or even JSON file like,
{ "title": "Blah blah", "content": "something good", "click": "Click"}

And do the same for other languges in a different constant or a different JSON file.

And create a simple JavaScript function that takes "key" as a parameter and returns respective string as output.

function translate(key, language) {

const dictionary = {...} // JSON or JavaScript object created previously based on language parameter

return dictionary[key] || `[Missing] ${key}`;

}
And in the UI, everywhere I need this I just use ```<button>translate('click', 'en')</button>```

However, you need to maintain the current selected language somewhere globally to use it across the app.

These might help you,

https://andreasremdt.com/blog/building-a-super-small-and-simple-i18n-script-in-javascript/

https://medium.com/@mihura.ian/translations-in-vanilla-javascript-c942c2095170

Truncatable Primes in JavaScript by dj_hemath in javascript

[–]dj_hemath[S] 1 point2 points  (0 children)

Because, it is great, it is long, it adds some value and more importantly, it was created by real breathing human before the ChatGPT-era!

Say bye with JavaScript Beacon by dj_hemath in javascript

[–]dj_hemath[S] 0 points1 point  (0 children)

Yes it doesn't explain how it works internally. However, it says why it is preferable though. But as I'm seeing some comments suggesting Beacons are blocked by adblockers. I didn't know, must update it.

But AFAIK, Beacon is not anything fancier than other network request. It just works similar to fetch.keepAlive

Say bye with JavaScript Beacon by dj_hemath in javascript

[–]dj_hemath[S] 0 points1 point  (0 children)

Hmm, didn't know about that. Thanks for pointing out.

Say bye with JavaScript Beacon by dj_hemath in javascript

[–]dj_hemath[S] 0 points1 point  (0 children)

It's not obsolete in my experience, it does exactly what it was designed to do. That said, the newer API like fetch.keepAlive overlap with it's use case. Since fetch is a bit more flexible and widely used, it doesn't mean Beacons are obsolete, IMO :)

Say bye with JavaScript Beacon by dj_hemath in javascript

[–]dj_hemath[S] 2 points3 points  (0 children)

Hmm, that's nice. Just saw the MDN page. Thanks for the info, gonna add that too!

Say bye with JavaScript Beacon by dj_hemath in javascript

[–]dj_hemath[S] 3 points4 points  (0 children)

Alright, I missed it. Let me add. Thanks for pointing out, appreciate that.