Under what circumstances would you use JavaScript?

Dani AI

Generated

The short thread by and starts the right conversation but doesn’t show the modern tradeoffs. Below is a compact decision checklist and practical notes that map common needs to today's options (and some current gotchas).

  • Use browser scripting when the goal is richer interaction inside the page: live filters, type‑ahead, drag‑and‑drop, client-side rendering for snappy UI, or partial updates without full page reloads.
  • Use Service Workers when offline support, background sync, or caching strategies are required (Service Worker API).
  • Use WebSockets or Server‑Sent Events for low‑latency push/real‑time updates (chat, live feeds).
  • Use server code (PHP, ASP/.NET, Node.js, etc.) for authoritative work: database access, secrets, payment flows, heavy aggregation or anything that must be trusted. Node.js is a good option when a single-JS stack and non‑blocking I/O are helpful.
  • Prefer JSON for modern APIs; XML is still used for legacy enterprise interfaces or rigid schema needs (JSON primer).
  • For CPU‑heavy or near‑native speed tasks, consider WebAssembly instead of legacy plugins (WebAssembly). Java applets are effectively obsolete and the applet API was officially deprecated (see JEP 289).

Example: fetch JSON and update a list (unobtrusive, minimal DOM work):

fetch('/api/items')
  .then(r => r.json())
  .then(items => {
    document.getElementById('list').innerHTML =
      items.map(i => `<li>${i.name}</li>`).join('');
  });

Cautions: never treat client-side state as authoritative — re-check on the server; serve pages over HTTPS; use Content Security Policy and output escaping to reduce XSS risk; use feature detection and polyfills rather than assuming every browser supports modern APIs.

Recommended Answers

All 5 Replies

hello,
java script is a client side scripting...means doing some operations with out sending requests to the server...means for example doing validation for a form before interacting with server...by this we are not waste the server time...

And read some javascript tutorials by googling...

hello,
java script is a client side scripting...means doing some operations with out sending requests to the server...means for example doing validation for a form before interacting with server...by this we are not waste the server time...

And read some javascript tutorials by googling...

Does that answer my question Shanti bhaji?

Does that answer my question Shanti bhaji?

Exaclty....
or again post your thread in detail...

Describe the circumstances when tecnologies such as Active Server Pages, PHP, JavaScript, JavaApplets,XML etc are required?

If you want to implement basic means static website,then go for html..
and if you want to implement dynamic website ,then choose asp or php what ever you like...
and javascript can be used in all server side technologies for the purpose validating...
and xml is for data sharing...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.