18 Matching Annotations
  1. Aug 2018
    1. WebExtension APIs in the script, as long as you have requested the necessary permissions.

      some web extensions require the use of permissions

    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. runtume

      *typo

    3. Webpack includes this runtime into the last generated chunk, which is vendor in our case

      confusing line!!

    4. In webpack terminology, separate files with the app code are called chunks

      webpack chunk definition

    5. 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.

    6. App dependencies tend to change less often than the actual app code

      vendor scripts

    1. One reason for this is

      why optimised bundled modules load time is much better than unbundled modules

    2. providing a fallback to other browsers

      For non module supporting browsers we can add another script tag with the nomodule attribute

    3. 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 ./

    4. 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.

    5. 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

    6. 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

    7. same goes for all the dependency modules

      Even the dependencies modules are defer by default

    8. 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.

    9. possible

      Sexy example below. Makes the concept of dynamic import crystal clear. Although one must know the concept of async await function.

    10. With modules, it becomes possible to develop websites without using bundlers such as webpack, Rollup, or Parcel

      Only when you have a small webapp