Frameworks80k+ stars

Svelte

Cybernetically enhanced web apps - a compiler, not a framework

Commit Details

Message
"first commit"
Author
Rich Harris
Date
2016-11-16
Hash
cf16ef3a0eba0d60af2a3d5bcf0b0bcc8e2e5d0c

Fun Fact

Rich Harris created Svelte while working at The New York Times. His blog post "Frameworks without the framework" introduced the compile-time approach.

</>First Code

JavaScript
// Svelte - Cybernetically enhanced web apps
// Compile-time framework by Rich Harris

function compile(source) {
  const ast = parse(source);
  const code = generate(ast);
  
  return {
    code,
    map: null
  };
}

// The revolutionary idea: shift work from runtime to compile time
// No virtual DOM, just surgical DOM updates

export function create_component(template) {
  return function mount(target) {
    const fragment = document.createDocumentFragment();
    // Svelte generates this at compile time
    return { fragment, update, destroy };
  };
}