What's the best way to load a JavaScript file in HTML? HTML async vs defer

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 พ.ย. 2024

ความคิดเห็น • 19

  • @carlinhamininel
    @carlinhamininel ปีที่แล้ว +4

    EXCELLENT EXPLANATION! 👏 great job, thanks a lot!

  • @danielmadison4451
    @danielmadison4451 ปีที่แล้ว +2

    Excellent! Thanks for the clear explanation. I am a purest and when I discovered you could put the 'script' tag ion the 'head' section I immediately started using it. But soon I was getting trouble. When I saw your video with the 'defer' attribute, LIKE MAGIC it started working. :)

  • @arankengineer7947
    @arankengineer7947 ปีที่แล้ว +2

    thank you sir for explaining the exactness of these

  • @farazk9729
    @farazk9729 ปีที่แล้ว +2

    Great video; thanks. Just a little something: in your slides, the first scenario was "script tag in the header", but I think you meant HEAD, not header, right? It could confuse some people: head VS header/footer.
    Edit: Toward the end of the video, you yourself pointed that out. Thanks.

    • @tapasadhikary
      @tapasadhikary  ปีที่แล้ว +1

      Yes, it's inside the tag. Thanks for pointing it out.

  • @sublimeelectrons8699
    @sublimeelectrons8699 ปีที่แล้ว +1

    Well explained. Straightforward like no other tutorial. Great content @tapas

  • @uchennachukwuba
    @uchennachukwuba ปีที่แล้ว +1

    Please take this comment as a token to motivate you to post more videos.👏👏👏
    I have liked and shared this video ❤

    • @tapasadhikary
      @tapasadhikary  ปีที่แล้ว

      Thanks a lot for the acknowledgment 😍

  • @highlightsalll
    @highlightsalll ปีที่แล้ว +2

    Great video thank you 🙏

  • @krishnakundana3533
    @krishnakundana3533 10 หลายเดือนก่อน +1

    Great content.

    • @tapasadhikary
      @tapasadhikary  10 หลายเดือนก่อน

      Thank you ❤️

  • @tapasadhikary
    @tapasadhikary  ปีที่แล้ว +1

    The first thing you learn in JavaScript is to load a JavaScript file into an HTML file. But do you know,
    - There are more than a couple of ways to do that?
    - Do you know the right way?
    - Do you care for the users who are on the slower network?
    This video teaches you how to load a JavaScript file so your users will not encounter performance and data loss issues. Learn about the async and defer HTML attributes to become a better developer.
    Don't forget, it is a tricky interview question too! 🤯
    Timecodes
    0:00 - Why care about Script loading?
    01:00 - The Secret Santa Game
    02:02 - Issue with loading a JavaScript file into the HTML Header
    06:15 - The dirty fix: Move it to the end of the body!
    07:45 - Understanding the problem visually
    10:20 - What is the async attribute in HTML, and when to use it?
    18:13 - What is the defer attribute in HTML, and when to use it?
    19:14 - async vs defer
    23:36 - Wrapping Up

  • @s-h-f
    @s-h-f ปีที่แล้ว +1

    Great video! One suggestion, I think you should keep the mic close to your mouth so you don't have to speak loudly and it won't echo much.

    • @tapasadhikary
      @tapasadhikary  ปีที่แล้ว

      Thank you! Also thanks for the echo suggestion. I guess it's my newly painted room 😀. I'll try taking care of it 👍