Message from JavaScript discussions

October 2020

— Fuck


It is not a big issue. once you are done with the dynamic part, you can just document.appendChild('<script src="other-script.js">') (roughly)

— And if you use type="module" you get free dynamic module loading.

— Only reason to use multiple script tags is if they are not related or code-splitted.

— Its a legacy system, I dont want to touch the legacy part

— What is your audience? IE?

— Ecommerce

— So the good news is, your users are probably tech-savvier by using an online platform to buy stuff, so they are likely using ever-green browsers (edge, chrome, ff, ...) and you can use type=module for scripts.
The bad news is, that your boss is probably a greedy ass and wants every single user to be able to connect to the website to not let a penny slip through 👀

Message permanent page

— Okay, sorry I was occupied with something else. I am now rewriting the stuff from the legacy system to dynamically add all the scripts up on some event. Problem is the order in which they are executed matters, so I am only loading the next script when the previous one is resolved with Promise and script.onload, but know I lose all the benefits of http2 and parallel fetching. Is there a quick and easy way to use Promise.all() for the scripts but execute them in order?

Message permanent page

— Prefetch

— Https://

— Actually preload*