Giter VIP home page Giter VIP logo

Comments (2)

hwang26 avatar hwang26 commented on July 21, 2024

Resources

https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/
https://requirejs.org/docs/start.html

Past

  • Libraries like jQuery were "imported" by assigning them to global variables
    • Global scope presents security risk due to hijacking
  • All subsequent scripts needed to be in a specific order
    • Hard to see dependencies, usually not explicitly stated
  • Mandatory Synchronous script loading

Modules

  • Provide organization of related code
  • Import/Export syntax provides dependency graph
  • Common JS
  • ECMA Script Modules

ES Module Spec

  • Import/Export dependency graph
  • File -> Module Record
  • Module Record -> Module Instance (Code + State)
  • 3 steps
    1. Construction
    • Files are converted to module records
    1. Instantiation
    • Module records are linked
    1. Evaluation
    • Code is ran and values are filled
  • The 3 steps can be ran asynchronously based on implementation
    • ES Modules spec: States how to get module records & instantitate & evaluate (Doesn't state how to get files)
    • Loader is what fetches the files (eg. HTML spec specifies loader in the browser)
  • Loader puppeteers the ES Module Spec (Calls Parse, Instantiate, Evaluate)

Common JS Spec

  • Node JS uses Common JS specs
  • Synchronous
    • Modules & Dependencies run the 3 steps all at once (no breaks in between)
  • Loading files from the filesystem takes less time than downloading files from the internet

Require JS

  • Asynchronous module loader
    • Advantageous when speed is a concern on the client-side, we don't want to block page rendering
    • eg. Node JS uses synchronous script loading on the serverside
  • AMD (Asynchronous Module Definition)
    • Has some extra quirks outside of Common JS specs (Haven't looked deeply into these)

Browserify

  • Common JS
  • Can be managed by npm

from mock-crud-app.

hwang26 avatar hwang26 commented on July 21, 2024

We'll go with Require JS as our solution

from mock-crud-app.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.