The Best Way to Include JavaScript Files in Your HTML — Modules & Defer Tutorial

preview_player
Показать описание
In today's video, I'll take you through a couple of problems when it comes to using the script tag and how you can get around by implementing some best practices: the defer attribute, and using modules.

For your reference, check this out:

If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!

#dcode #javascript #webdevelopment
Рекомендации по теме
Комментарии
Автор

Clean, fast and slim, only necesssary information.👍👍👍 Thank you!

licokr
Автор

Learning something new every day, thank you bro

dev_ression
Автор

You can use alt+up/down arrow to move current line up or down instead of copy paste.

fuadcs
Автор

I have been using the "defer" method for a while. The use of the "module" method is acceptable, but it is more beneficial for developers who have experience with frameworks of any kind and will not be confusing for them. On the other hand, using the "import" method might be useful for learning JSX syntax and preparing ourselves for frameworks.

TomasMisura
Автор

Thanks Dom! Great content and very helpful!! I am currently working on a project that uses modules and it is very difficult for me to debug issues for exactly the reason you pointed out. Is there a workaround for accessing variables in my main.js module? I have a bunch of other js files that main.js is importing and really need to keep it as a module. Thank you for all your in-depth and super informative videos!!

kerrykreiter
Автор

Man's been on a role lately, innit.

bmehder
Автор

what was the disadvantage to wrap everything into the domContentLoaded listener?

tamas-pamas