Categories
Build Tools JavaScript webpack

webpack 3: Scope Hoisting and the Bundle Size Wars

webpack 3 just shipped with a feature called "scope hoisting" that makes bundles smaller and faster. The technical improvement is modest—5-15% bundle size reduction in practice—but the symbolism is significant. webpack is acknowledging that bundle size matters, and the ecosystem is finally taking performance seriously.

What Is Scope Hoisting?

Scope hoisting (via the ModuleConcatenationPlugin) changes how webpack wraps modules. Previously, webpack wrapped each module in a function:

// webpack 2 output (simplified)
[
  function(module, exports) {
    // your module code
    var foo = require('./other');
  },
  function(module, exports) {
    // other module
    module.exports = 'bar';
  }
]

Each module gets its own scope. This is safe but bloated—lots of function wrappers and runtime overhead.

Categories
Frontend JavaScript React

React Fiber: Rewriting the Core Without Breaking Everything

React is undergoing a complete core rewrite called Fiber, and most developers won't notice. That's the point. Facebook is replacing React's reconciliation algorithm—the diff engine that makes React fast—without changing the public API. This is a remarkable engineering feat and a lesson in managing large-scale architectural changes.

What Is Fiber?

Fiber is a complete rewrite of React's core algorithm. The current version (React 15) does reconciliation synchronously—when state changes, React computes the entire component tree diff in one uninterruptible block. If that takes 100ms, the main thread is blocked for 100ms. No user input, no animations, nothing.

Fiber breaks reconciliation into chunks. React can pause diff work, check if there's higher priority work (like user input), handle that, then resume diffing. The result: smoother user experiences, especially on slower devices.

Categories
JavaScript Performance WebAssembly

WebAssembly MVP Ships: Native Speed in the Browser

WebAssembly (WASM) is shipping in Chrome, Firefox, and Edge. Safari support is coming. For the first time, we can run compiled languages in the browser at near-native speed. This is a huge technical achievement, but the practical implications are still unclear.

What Is WebAssembly?

WebAssembly is a binary instruction format that browsers can execute. Write code in C, C++, or Rust, compile to .wasm, and run it in the browser. No plugins, no VMs—it's baked into the browser alongside JavaScript.

// Load and instantiate WebAssembly
fetch('module.wasm')
  .then(response => response.arrayBuffer())
  .then(bytes => WebAssembly.instantiate(bytes))
  .then(results => {
    const exports = results.instance.exports;
    // Call WASM functions from JavaScript
    const result = exports.add(5, 3);
    console.log(result); // 8
  });

The performance wins are real. Benchmarks show 10-800x speedups over JavaScript for compute-heavy tasks. Parsing and compiling WASM is faster than JavaScript because the binary format is optimized for quick validation.

Categories
Mobile PWA Web Development

Progressive Web Apps: Real World Results

Progressive Web Apps launched as concept a year ago. Now we have case studies: Flipkart (India), AliExpress (China), Washington Post (US) all report significant metric improvements after building PWAs. The data suggests PWAs work—but the adoption pattern is interesting.

PWAs are succeeding most where app stores create most friction.

The Results Are In

Categories
HTTP Performance Web Development

HTTP/2 is Here and It Changes Everything (Theoretically)

HTTP/2 is shipping in browsers and servers throughout 2016. The protocol brings multiplexing, server push, and binary framing—fundamental changes that supposedly invalidate HTTP/1.1 optimization practices like domain sharding and sprite sheets.

Reality is messier. Not all browsers support it. Not all servers either. And some HTTP/1.1 optimizations still help. The transition period is awkward.

What HTTP/2 Changes

Categories
Architecture JavaScript Web Development

Isomorphic JavaScript: Same Code, Client and Server

"Isomorphic JavaScript" is gaining traction—write code that runs on both server and client. Render on the server for fast initial load, hydrate on the client for interactivity. The promise is having your cake and eating it too: server-side performance with client-side dynamism.

After building a few isomorphic applications, my take: it's powerful but not simple. You're not writing code once, you're writing code that accommodates two environments.

The Problem Being Solved

Categories
Architecture Backend Development JavaScript Node.js

Node.js 0.10: JavaScript Everywhere is Finally Serious

Node.js 0.10 landed in March, and it feels like a turning point. Not because of specific features—though the performance improvements are real—but because it signals maturity. Companies are betting on Node for production systems, not just side projects. That shift deserves examination.

The Event Loop Thesis

Categories
Database MySQL Performance

Optimizing MySQL Query Performance

Introduction

Your web application is slow. Pages take seconds to load. Users are complaining. You check your code – it's fine. You check your server – plenty of resources. The problem? Your database queries.

Database performance is often the bottleneck in web applications. A poorly optimized query can turn a fast application into a sluggish mess. But with the right techniques, you can make your database scream.