Why the Fastest Code Is Often the Most Delayed

Kai Nguyen

Hatched by Kai Nguyen

Aug 03, 2026

9 min read

86%

0

The Strange Art of Knowing What Must Wait

What if the difference between slow software and fast software is not how much work it does, but when it does it? That question sounds almost too simple, yet it hides a deep pattern that appears everywhere: in graphs, in browsers, in systems design, and in the way we structure work itself. Some things can begin immediately. Some things must wait. The skill is not merely execution, but ordering.

That is the quiet connection between dependency graphs and script loading strategies. A topological ordering turns a messy web of prerequisites into a valid sequence. Deferred execution lets a browser keep moving while honoring the fact that some scripts depend on a fully parsed document. Both are about respecting constraints without freezing progress. Both ask the same question in different languages: What can safely happen now, and what must be postponed?

Most people think performance comes from speed in the obvious sense. Faster downloads, faster loops, faster machines. But the deeper performance trick is often coordination. The most elegant systems do not eliminate dependency. They make dependency legible, then schedule around it.


Dependency Is Not the Enemy, Confusion Is

A dependency is simply a relationship of necessity. One thing must exist before another can make sense. In a graph, that appears as a node with incoming edges. In the browser, it appears as a script that needs the DOM to be available before it can manipulate it. The problem is not dependency itself. The problem is when dependency is treated as if it were chaos.

Topological sort gives us a formal answer to that chaos. It takes a partial ordering, where some items depend on others, and produces a linear ordering that respects those constraints. Sources and sinks become useful mental anchors: a source has no incoming edges, so it can start immediately. A sink has no outgoing edges, so it represents a terminal outcome. Between them lies the useful discipline of sequencing.

This matters because many failures are really sequencing failures in disguise. A build pipeline breaks because a generated file is consumed before it exists. A page loads slowly because a script blocks parsing when it does not need to. A team misses a deadline because everyone is working, but not in an order that allows work to accumulate. When the dependency structure is invisible, the system feels arbitrary. When the dependency structure is explicit, the system becomes schedulable.

The first job of any intelligent system is not to move faster. It is to reveal the order in which things must be allowed to happen.

That is why topological thinking is bigger than graph algorithms. It is a philosophy of respecting prerequisites. It says: do not force simultaneity where sequence is required, and do not force sequence where simultaneity is safe.


Async and Defer Are Not Just Browser Flags, They Are Scheduling Philosophies

The browser gives us a perfect everyday example. HTML parsing is a stream of possibility, but JavaScript can interrupt that stream in different ways. If a script blocks parsing while it is fetched and executed, the page slows down because one dependency is treated as if it owned the entire timeline. If the script is downloaded asynchronously, the browser keeps parsing. If execution is deferred until after parsing, the page can become structurally complete before the script takes its turn.

These two approaches are not merely technical options. They encode two different beliefs about work.

Async says: get the resource as soon as possible, then run it as soon as it is ready. This is excellent when the script is independent and does not need a carefully preserved order relative to other scripts or the DOM. It prioritizes availability.

Defer says: download in parallel, but wait to execute until the document is ready. This is better when the script depends on the final structure of the page or on the relative ordering of other deferred scripts. It prioritizes correctness of context.

The difference is subtle but profound. Async optimizes for earliest possible execution. Defer optimizes for safe and meaningful execution. In other words, one is about reducing latency, the other about preserving topology. The browser is not just loading code. It is solving a scheduling problem under constraints.

That same decision appears in more familiar situations than web development. Imagine opening a restaurant. Some tasks are like async scripts: preheating ovens, brewing coffee, or fetching ingredients can happen in parallel without waiting for the dining room to be fully set. Other tasks are like defer scripts: plating the final dish should wait until all components are ready and the table is prepared. The best kitchen does not rush every action. It assigns timing according to dependency.

This is why simply asking “How do I make it faster?” is often the wrong question. A better question is: Which operations are truly independent, and which ones merely appear urgent?


The Hidden Metric: Throughput Without Premature Commitment

There is a deeper lesson here about what makes systems feel responsive. Responsiveness is not always about finishing everything immediately. Often it is about allowing useful work to proceed while irreversible commitments are delayed until the structure is ready.

Topological sort is powerful because it respects a partial order without pretending the world is flat. The browser loading model is powerful because it allows downloading and parsing to overlap, while postponing execution when necessary. In both cases, the system gains efficiency by separating preparation from commitment.

That distinction is worth naming.

Preparation includes fetching, parsing, planning, and staging. It is work that can often happen ahead of final readiness. Commitment includes execution, mutation, publication, and any action that depends on the full context being in place. Confusing these two is one of the most common reasons systems become brittle.

Consider a software deployment. You can build artifacts, warm caches, validate configuration, and prefetch assets before the switch is flipped. But flipping the switch itself should happen only when the dependencies are satisfied and the environment is coherent. Or consider writing. Research is preparation. Publishing is commitment. If you publish before the argument has a stable structure, you pay the price later in corrections, contradictions, and reader confusion.

The most effective systems, whether technical or human, use parallelism for what can be parallelized and sequence for what cannot. They do not maximize concurrency indiscriminately. They maximize meaningful concurrency.

Speed is not the opposite of order. The best speed comes from discovering the right order.

This is what makes the overlap between graph theory and browser behavior so revealing. One is usually taught as an algorithmic technique, the other as a front end performance optimization. But they are both forms of the same meta skill: scheduling work in the presence of dependency.


A Mental Model: Sources, Sinks, and the Waiting Room of Work

A useful way to apply this idea is to imagine every project as a directed graph.

  • Sources are tasks with no prerequisites. They can begin immediately.
  • Intermediate nodes are tasks that depend on earlier outputs.
  • Sinks are tasks that complete the system or deliver the final value.

Now add one more layer: not every node must block every other node. Some tasks can be started early, but not finished early. Some can be downloaded, prepared, or outlined while waiting for other parts to settle. This is exactly what modern browsers exploit when they handle scripts with async or defer. They do not collapse all work into one rigid queue. They separate when work can be acquired from when work can affect the world.

That model is surprisingly transferable.

For example, in product development, user research can be gathered before the full feature set is designed. In hiring, reference checks can happen in parallel with final approvals. In data engineering, raw ingestion can begin while schemas are being refined. In each case, the trick is to identify which steps are sources of progress and which are sinks of finality.

A source is not just a task with no prerequisites. It is a task that can generate momentum without waiting for the rest of the system. A sink is not just an endpoint. It is the place where all the gathered dependencies resolve into a coherent outcome. Between source and sink lies the true work of architecture: deciding how much can be made concurrent without breaking causality.

This is where many teams go wrong. They optimize each task locally, then wonder why the whole feels slow. But a graph does not care how fast a node is if the node appears in the wrong place. Likewise, a browser does not benefit from a script being fast if loading it at the wrong moment stalls the document. Local speed does not guarantee global performance.

What matters is the shape of the dependency structure, and whether the system honors it intelligently.


Key Takeaways

  1. Ask dependency first, speed second. Before optimizing, identify what truly depends on what. Many bottlenecks are sequencing problems, not raw performance problems.

  2. Separate preparation from commitment. Downloading, parsing, and staging can often happen early. Execution, mutation, and publication should wait until context is safe.

  3. Use parallelism only where it preserves meaning. Async work is valuable when independence is real. Defer is valuable when order or context matters.

  4. Think in graphs, not just tasks. A project, page, or pipeline is rarely a line. It is a network of sources, intermediates, and sinks. Mapping that network reveals opportunities for speed without chaos.

  5. Optimize the system, not the component. A fast node in the wrong position can still slow everything down. The best performance often comes from better orchestration, not more urgency.


The Real Lesson: Intelligence Is the Ability to Wait Correctly

We usually treat waiting as wasted time. But in systems with dependencies, waiting can be an active form of intelligence. The browser waiting to execute a deferred script is not being lazy. It is preserving the conditions under which the script will be useful. A topological sort does not hesitate because it is confused. It waits because it knows that order is part of correctness.

That is the real synthesis here: the most sophisticated systems are not those that do everything as soon as possible. They are the ones that know how to postpone the right things for the right reasons. They exploit concurrency where possible, but they never let haste destroy structure.

So the next time you face a slow process, do not only ask what to accelerate. Ask what should be downloaded early, what should be executed later, what is a source, what is a sink, and what ordering makes the whole system coherent. The answer may not just make your code faster. It may make your thinking clearer.

In the end, the fastest systems are often the ones that have learned the oldest lesson in disguise: progress is not the same as motion, and motion is not the same as order. The moment you understand that, you stop trying to outrun dependency and start designing with it.

Sources

← Back to Library

Hatch New Ideas with Glasp AI 🐣

Glasp AI allows you to hatch new ideas based on your curated content. Let's curate and create with Glasp AI :)

Start Hatching 🐣