18 Matching Annotations
  1. Aug 2018
    1. Split the code into routes and pages

      Instead of having a single large bundle file for your whole website, you can have multiple bundles for each page. This improves the load time of your website as you can tag bundle files to the various webpage of your site instead of one initial big download of script file.

    2. With webpack, you do the same, but instead of a version number, you specify the file hash.

      Webpack caching using [chunkhash] is just like creating version number for your script file. filename.[chunkhash].js [chunkhash] can be assumed to be version number which the browser uses to check if the file has changed or not, and according to it updates the file in its cache.

    1. module specifier

      import * from "./abc.js"; This string inside the double quotes is called MODULE SPECIFIER. It is used to specify the location of the module relative to the current folder or the root folder depending on wether we used / or ./

    2. async attribute,

      Scripts with the async attribute are loaded(downloaded) from the server asynchronously. That means there is no order in which the script is going to be executed. It doesn't block the HTML parser Script is executed as soon as it is downloaded, does not wait for HTML parsing to finish.

    3. Also, module scripts and their dependencies are fetched with CORS. This means that any cross-origin module scripts must be served with the proper headers, such as Access-Control-Allow-Origin: *. This is not true for classic scripts.

      CORS - Cross Origin Resource Sharing

    4. mjs

      modules have .mjs extension Not really important We can use .js as well The type attribute in our script tag is enough RECOMMENDED : We should use .mjs extension because during development it makes it easier to diffrentiate

    5. Browsers that understand type="module" ignore scripts with a nomodule attribute.

      Only the latest browsers are module-supporting. For these browsers you can use a script tag with a type attribute set to module.