Skip to main content
Languages

JavaScript

Use the browser's language without making every interaction depend on it.

A product needs a faster search, an account workflow or a live status update. JavaScript can add that behaviour to the page, or it can become the runtime for the whole interface, build pipeline and backend. Both are valid. The mistake is allowing a small interaction to decide the architecture of the entire product without examining what customers must download, execute and recover from when code fails.

JavaScript is the native programming language of the web platform. That makes it unavoidable for some browser behaviour, though content and navigation can work without it. The decision is how much work belongs in the browser and how much complexity the product can support over time.

JavaScript is unavoidable in the browser but its footprint is optional

An HTML form can submit without client code. JavaScript can then add inline validation, conditional fields and a faster response. This progressive route preserves a working baseline while improving the experience where the browser supports it.

A collaborative editor, mapping tool or complex account application may need sustained client state and a component framework. In that case JavaScript is a core application layer and deserves architecture, tests, release monitoring and an explicit performance budget.

We start with the customer task and failure behaviour. If a script is delayed, blocked or throws during startup, can the customer still read the page, move through the site or complete the transaction? The answer sets an upper bound on how dependent the experience should be on client execution.

The runtime boundary decides which APIs and guarantees exist

ECMAScript defines the language. The host supplies the useful environment around it. Browsers provide the DOM, storage, network requests and workers. Node.js supplies server processes, files and its own module and deployment concerns. Extension contexts add permissions and isolation rules.

Code that assumes window, a Node built-in or a particular global cannot move between these hosts without adaptation. Even shared packages should state their target runtimes, module formats and supported versions.

We keep environment-specific code at the edge and put shared rules behind plain inputs and outputs. This makes tests easier and prevents a package described as universal from importing a browser or server dependency deep inside its graph.

Modules need one deliberate delivery path

Native ES modules give the language a standard import and export model. A production codebase may still involve package resolution, transpilation, code splitting and compatibility transforms. Adding several overlapping paths creates defects that appear only in a test runner, server render or production build.

We decide whether the browser consumes native modules directly or whether a tool such as Vite owns transformation and bundling. Package exports, file extensions, source maps and dynamic imports are configured for the runtime in use rather than copied from a library template.

The production artefact is inspected. A successful build does not prove that a route loads only the code it needs or that a supposedly lazy feature stayed out of the initial bundle.

Async syntax does not move CPU work off the main thread

Promises and async functions make asynchronous control flow easier to express. They do not cause a large calculation to run on another thread. Synchronous work before or after an await still occupies the current JavaScript agent.

In a browser, a long task delays rendering and input. We split work, reduce it, move suitable computation to a worker or perform it on the server. A worker cannot manipulate the DOM directly, so message shape and transfer cost belong in the design.

Asynchronous operations can also complete in an unexpected order. Search results, autosave requests and route transitions need cancellation, sequencing or stale-result checks. The event loop prevents two jobs from executing JavaScript at the same instant on one agent; it does not make business state immune to races between completions.

Browser support should be a product policy

The right compatibility target comes from customer evidence, contractual requirements and the cost of a degraded experience. A list of versions with defined essential journeys can be tested, which a generic promise to support every browser cannot.

We use feature detection for optional browser APIs and keep a fallback for the customer task. Transpilation can change syntax, while polyfills and alternative implementations cover selected APIs. Neither should be assumed to reproduce every platform behaviour.

Automated cross-browser tests cover high-value flows, and real-user error and performance data shows what escaped the test set. Removing an old compatibility layer is then a product decision backed by usage rather than developer preference.

The dependency graph is shipped code and build infrastructure

A small package can bring many transitive dependencies into the build. Some execute in the browser, some only during development and some run scripts during installation. Each path affects security, update work and whether a future build remains possible.

We prefer platform APIs and focused packages where they keep the code clearer. Before adding a dependency, we inspect its maintenance, licence, release history, bundle effect and transitive graph. The lockfile is committed, automated audit findings are triaged and major updates are tested rather than accepted by a bot without context.

Fewer dependencies are not automatically safer if the replacement is unreviewed local code. The useful target is a graph small enough for the team to understand and maintain.

Dynamic data needs runtime checks at trust boundaries

JavaScript will accept shapes that the developer did not intend. Even a TypeScript codebase receives untyped data from HTTP responses, storage, messages, forms and third-party scripts once it runs.

We validate untrusted input at the boundary and return useful errors. Internal functions can then operate on a narrower, documented shape. This is particularly important for payment callbacks, extension messages and persisted browser state, where an old or hostile payload may outlive the code that first created it.

Runtime validation belongs where external data enters the system, so private functions do not each need their own checks.

Observability must preserve the user journey

A server log cannot show that a customer clicked a button whose handler failed before the network request. Browser error reporting, release identifiers and source maps provide that missing evidence, but they must be configured to avoid collecting secrets and personal data.

We monitor failed resource loads, unhandled promise rejections and performance for actual customers. Measures are segmented by route, device and release so a regression on slower phones is not hidden by desktop averages.

Performance optimisation starts with the user task: how soon useful content appears, whether input receives a response and whether later interaction remains stable. Bundle size is one contributor, not the outcome by itself.

Questions to answer before expanding the JavaScript layer

  • Which customer tasks require browser execution rather than server-rendered HTML?
  • What remains usable when JavaScript is delayed or fails during startup?
  • Which runtimes and browser versions are supported and tested?
  • Does one tool own modules, transformation, bundling and source maps?
  • Which work can block the main thread under a slower device profile?
  • How are stale async results, cancellation and repeated submissions handled?
  • Which dependencies reach customers and who reviews their updates?
  • Would TypeScript, a framework or an HTML-first design reduce more risk than it adds?

When JavaScript is enough on its own

Plain JavaScript is a strong choice for focused interactions, progressive enhancement, browser extensions and small interfaces whose state can remain local and understandable. Native platform capabilities now cover much of the work that once required a library.

It can also support a substantial application when the team sets clear modules, data boundaries and testing standards. Without a framework the team still needs an architecture, and has to choose it themselves.

When stronger constraints should be added

A large team changing shared domain models may benefit from TypeScript. A state-heavy interface with repeated composition and routing needs may justify React or Vue. A content-led journey is better served by cutting client JavaScript than by adding another framework.

The wrong signal is file count alone. Add a tool when it reduces a demonstrated coordination, correctness or delivery cost, and record the new upgrade duties it introduces.

Alexander De Sousa, Founder of Digital Royalty
Developer’s verdict

Use JavaScript where the customer benefits from browser execution, and keep the dependency on it proportionate.

I start with what the customer must still be able to do when a script is late or broken. For a focused interaction, I prefer the browser platform and a small amount of JavaScript. For a rich application, I accept a framework and build system when they solve known state and team problems. Either way, I want the runtime boundary, browser policy, dependency graph and main-thread budget visible. Ubiquity is a reason to use JavaScript carefully, not permission to move every product concern into the browser.

Alexander De Sousa · Founder, Digital Royalty · LinkedIn

Decision evidence

What changes as JavaScript takes on more of the product

JavaScript can enhance an HTML journey or own a complete client application. Runtime, performance and dependency obligations grow with that role.

The JavaScript commitment in six decisions

Best fit
Browser interaction, extensions and client applications where immediate local behaviour provides clear customer value.
Product effect
Richer interaction and shared web skills, balanced against download, execution, compatibility and client-side failure cost.
Adoption cost
Low for progressive enhancement; moderate for a build pipeline; high for a state-heavy client platform with several rendering modes.
Ongoing owner
Frontend engineers responsible for browser policy, modules, dependencies, runtime validation, performance, accessibility and client diagnostics.
Exit cost
Low for isolated enhancements; high when navigation, rendering, state and backend contracts are coupled to one client architecture.
Main risk
Letting convenient client code become a mandatory, slow or fragile path for tasks that could retain a dependable HTML baseline.

Browser delivery routes to compare

  • Progressive JavaScript

    Right when: Choose when server-rendered pages work independently and JavaScript improves a bounded interaction.

    Watch for: Resilient and light, with more care needed to preserve behaviour across enhanced and baseline paths.

  • Framework client application

    Right when: Choose when routing, shared state and repeated interactive composition justify a dedicated browser application architecture.

    Watch for: Strong component and tooling ecosystems, with higher runtime and upgrade ownership.

  • TypeScript application

    Right when: Choose when shared contracts and refactoring across a growing team need static feedback before code reaches the browser.

    Watch for: Better development-time coordination while runtime validation and JavaScript behaviour still remain.

  • HTML-first product flow

    Right when: Choose for content and transactional journeys where the server can own navigation, validation and state with small optional enhancements.

    Watch for: Less client complexity and stronger baseline behaviour, but fewer app-like local interactions.

Research behind this JavaScript position

  • Language standard
    ECMAScript language specification

    Defines the language itself, separate from browser, Node.js and other host APIs that determine where JavaScript code can run.

  • Platform reference
    MDN JavaScript execution model

    Explains agents, jobs and run-to-completion behaviour, providing the basis for reasoning about main-thread work and asynchronous completion order.

  • Module guidance
    MDN JavaScript modules

    Covers native imports, exports, module loading and differences that appear between browser and server hosts.

  • Browser performance guidance
    web.dev: optimise long tasks

    Shows how long main-thread tasks delay input and why yielding or splitting work can improve browser responsiveness.

  • Package security guidance
    npm dependency security audits

    Documents dependency audits and the need to review advisory context rather than treating every automated suggestion as an unconditional update.

  • Ecosystem survey
    State of JavaScript 2025 usage and pain points

    The respondent survey identifies architecture, state, dependencies, performance and build tools as common concerns; it is a directional sample, not market truth.

  • Practitioner async question
    Stack Overflow: asynchronous JavaScript race conditions

    The discussion distinguishes single-agent execution from unpredictable completion ordering when several asynchronous operations are in flight.

  • Community dependency discussion
    Reddit: JavaScript's dependency problem

    Practitioners debate dependency quantity and quality. It is anecdotal evidence for reviewing maintenance and graph cost package by package.

Get started

Tell us what you need

A few quick questions, then a straight answer from a real person — usually within a few hours.

What happens next

  1. 1 We reply A real person reads your answers and gets back to you, usually within a few hours.
  2. 2 Questions or a short call If anything isn't clear, we ask by email or book a short call. Before any call we audit your website and make the quick fixes it finds, free.
  3. 3 Your fixed quote A clear, fixed price in writing, within 48 hours of any call. There is no obligation to go ahead.

Tell us what you're working on

Whether it's a new site, a platform, or a process that shouldn't be manual any more — we'll tell you honestly if we can help.