RequireJS


  • Module
  • Dependency
  • Bundle
  • Home task

Module

define([], function () {

  return function MenuWidget() {
    this.showMeHere = function (element) {
    };
  };

});

Dependency

  • Makes code clean
  • Explicit dependency specification
define(["jquery", "text!./MenuView.html"], function ($, MenuView) {

  return function MenuWidget() {
    this.showMeHere = function (element) {
    };
  };

});

Bundle

Home task

  • Main content widget
  • Weather widget (advanced)
    • $.ajax({ dataType: "jsonp", url: "http://openweathermap.org/data/2.0/weather/city/709930", success: function(r){console.log(r)}})
    • Animated appearance



RequireJS

By Vladimir Gaevoy

RequireJS

  • 1,423