Introduction to Building Custom Web Components

Поделиться
HTML-код
  • Опубликовано: 1 окт 2024
  • This video explains the fundamentals of creating custom Web Components for your web sites. Topics covered are:
    - classes that extend HTMLElement;
    - customElements.define method;
    - templates and slots;
    - shadowRoots and why we need them.
    Github Repo with code from video: github.com/pro...
    Using HTML5 Templates - • Using HTML5 Templates
    cloneNodes and creating HTML Templates - • cloneNode Method and C...

Комментарии • 66

  • @heshanwijerathna
    @heshanwijerathna Год назад +14

    Your channel is a gold mine. And some day this channel will become every ones favorite. I learned lot from you.

  • @mohamedelkhalil1288
    @mohamedelkhalil1288 8 месяцев назад +1

    Great video! I gotta ask, how can I build js headless packages?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  8 месяцев назад

      The only tutorial I have on anything headless is this one - ruclips.net/video/nIJV-LbV_vM/видео.html

  • @Aquilesxd
    @Aquilesxd 2 месяца назад

    Amazing video! My coleague and I has been studying this subject, and you are the only one who got that deep into it! Just one question: is there any way to document our web components so that the IDE can help whoever is using them?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  2 месяца назад +2

      @@Aquilesxd a great way to do this is to make them into a public repo on github and add the Readme.md file at the root where you provide all the information.
      Also include demo code or an example webpage using the component

    • @Aquilesxd
      @Aquilesxd 2 месяца назад

      @@SteveGriffith-Prof3ssorSt3v3 I see, thanks a lot! Again, amazing work man, keep it up!

  • @jeanmarcpourchel307
    @jeanmarcpourchel307 Год назад +2

    i agree with Heshan wijerathna!.....biggest gold mine ever!!!
    Very good idea, very good explanations!
    it's very usefull before learning frameworks such as angular ( even though it's typescript) or vuejs!
    And as always....thanks for teaching and sharing!!!

  • @ranathedev
    @ranathedev Год назад +2

    Thanks a bunch, sir! Your explanation is just amazing. This is the first video I've watched of yours and already subscribed to complete all of the series you've made free for us to learn. Thank you for your efforts! 🙏

  • @emirmasinovic
    @emirmasinovic 9 месяцев назад

    Is using innnerHTML safe in this case? If yes, then what would be the point of using a framework? What would other strong points for it be?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  9 месяцев назад +1

      innerHTML is only ever safe if the values that you are putting into it are completely controlled by the developer and not using user provided content.

  • @AniishAu
    @AniishAu Год назад +1

    Bah! I thought you could only do that in React!

  • @Bengadeer
    @Bengadeer 4 месяца назад

    I've built the various web components in this series and they worked great...in VS Code. Why don't they work when I open the index.html in a native browser? The CSS and active JS don't seem to wake up.

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  4 месяца назад

      Are you importing the module for the component?

    • @Bengadeer
      @Bengadeer 3 месяца назад +1

      @@SteveGriffith-Prof3ssorSt3v3 I figured it out. First: yep module called. The issue is Chome called me out on a CORS violation for this code loading directly to the browser.

  • @fernandoarnaldovilanculo8286
    @fernandoarnaldovilanculo8286 3 месяца назад

    Thank you sir! Keep it up!

  • @ROSSNKUNGA
    @ROSSNKUNGA 7 месяцев назад +1

    Steve you are a gift, i am so lucky to have you as my JS professor in my school program and program coordinator, you are so dedicated, 🔶, I understand this concept in a simple way wow! Be blessed Steve i love you and what you do for us and the rest of the world 🙌🦾

  • @OK-qy3ir
    @OK-qy3ir 8 месяцев назад

    Great video! A question about the web components. How does the search engine read the web components, it is a shadow-root ... Is the rendered content indexed? How does the search engine handle it? Thanks a lot Steve!

  • @Anonymouzee
    @Anonymouzee Год назад

    good info... ?where is the link for the video on templates?

  • @fahdfuhaid573
    @fahdfuhaid573 3 месяца назад

    Thanks ... very helpful series. i hope we see multi components put together to make a web app.

  • @cristian702
    @cristian702 6 месяцев назад

    LOVE IT!

  • @zerqs
    @zerqs Год назад

    I was searching your channel for a guide last night for web components , wow :D

  • @chhavimanichoubey9437
    @chhavimanichoubey9437 Год назад

    this was absolutely weird concept for me.

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  Год назад +1

      It is become a more common practice with large companies so they can standardize building their sites. There are many libraries of components available too.

    • @chhavimanichoubey9437
      @chhavimanichoubey9437 Год назад +1

      @@SteveGriffith-Prof3ssorSt3v3 thanks for the head's up.

  • @sinamobasheri
    @sinamobasheri 6 месяцев назад

    Beautiful Beautiful ❤ Thanks Steve

  • @aileenchan3741
    @aileenchan3741 Год назад

    Wow, what a great video! Thank you for making this video and so happy I found it! Is this the same approach React is doing when creating components? Like when in React we pass {children} to a parent component, but in Vanilla JS it is with ? I feel like I don't know Vanilla JS well enough, wow!!! Excellent video!

  • @ssikarim
    @ssikarim Год назад

    Thanks Steve,
    Is it a good practice to build html elements in js with template literals ?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  Год назад

      If you are building web components yes. Much easier that creating elements and slots individually through the script and appending them to the shadow root

  • @abulabbas1581
    @abulabbas1581 Год назад

    Hi thanks for this knowledge great learning .. Where can i get the whole documentation about this web components ? Kindly share the link if possible Thanks

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  Год назад +1

      Here is my full playlist for Web Components - ruclips.net/video/j0qG-afD244/видео.html
      The mozilla developer network site has lots of notes about web components.
      So does the google web.dev site.
      www.w3.org/TR/components-intro/ - is the official spec for web components.

  • @tomatescript
    @tomatescript Год назад

    Thanks for the video Steve, your explanation is really good and direct to the point!

  • @jezza10181
    @jezza10181 Год назад

    Nice explanation

  • @RajibAhmad
    @RajibAhmad Год назад

    Thanks a lot Steve for all those priceless tutorials.... simply amazing

  • @johnm8358
    @johnm8358 Год назад

    when should i use web components over React/Vue components?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  Год назад +3

      They are two separate things. With the frameworks you are building components that work within the one site that you are currently building with that specific framework.
      Web Components are something that you can build and then reuse on any site that you want with or without a framework.

  • @sovereignlivingsoul
    @sovereignlivingsoul Год назад

    excellent video, nice explanations, I have just started looking into web components and this was an excellent resource, look forward to your other videos.

  • @D7460N
    @D7460N 9 месяцев назад

    Thank you for this video. Very straightforward. Look forward to watching your other videos.
    Is shadowdom required for native web components?
    Also, is JavaScript registration of the custom HTML tag required to display content?
    Or is JavaScript registration necessary to display dynamic content?
    Thanks again!

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  9 месяцев назад

      shadowdom is how custom elements are added to the dom to create a "safe space" for them to have contained CSS that doesn't impact the rest of the page.
      To use a custom element you do need to register it. If you don't then the browser will treat your like a span with no CSS or behaviour.

    • @D7460N
      @D7460N 9 месяцев назад

      @SteveGriffith-Prof3ssorSt3v3
      Thank you for the reply. Apologies for my ignorance, but in light of keeping things simple if possible, isn't it easier to simply target the custom HTML tag for styling rather than taking on additional complexity with shadowdom? What am I missing?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  9 месяцев назад

      @@D7460N The ShadowDOM is automatically there around any custom element. The purpose of the shadowDOM is to isolate and protect the page from the element and the element from the page. We don't want styles from one transferring to the other and impacting the appearance of other things. There are a few basic styles that cascade down from the page to the HTML inside the custom element but not many.
      You wouldn't want to define a component with wild colours and have that leak out on to every website that uses the component.

  • @whitehat4u
    @whitehat4u Год назад

    excellent!, add about ShadowCSS and it's perfect ;)

  • @ahmedsalahabdullah2317
    @ahmedsalahabdullah2317 Год назад

    thank you

  • @komkwam
    @komkwam Год назад

    Wasn't this what xhtml was all about, to make your own tags?

  • @hericklenin
    @hericklenin Год назад

    Great material, thank you for this. Why main.js is the parent of the bigbang.js?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  Год назад +1

      It's not. main.js is there just to prove the point that you do NOT need to import bigbang.js
      It just needs to be loaded and run. the customElements.define() command is the part that does all the work.

    • @hericklenin
      @hericklenin Год назад +1

      @@SteveGriffith-Prof3ssorSt3v3 Awesome! Thank you.

  • @mohammedabdulaziz3658
    @mohammedabdulaziz3658 Год назад

    Nice

  • @amankumarraj5090
    @amankumarraj5090 Год назад

    Hey Steve Sir. I am going through your video tutorials. They are really wall made, appreciate it.
    I have a question which would like you to address. I am willing to create an html page using Javascript function which will be stored in the Website's database and has a link address to access the created page. The Javascript function will be linked to a button which when clicked, a page is created.
    Do answer this query of mine.

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  Год назад

      What website database are you talking about? The .hosts file? IndexedDB? Cache API? Web SQL? something else? Really not sure what you are asking. Not something I can really answer in a comment though.

    • @amankumarraj5090
      @amankumarraj5090 Год назад

      @@SteveGriffith-Prof3ssorSt3v3 I am referring to any database which can store the newly created html pages in it.
      The functionality i am talking about is that => A button will be provided in a website and whenever the button is clicked by a user, it will automatically generate a new page with the extension .html which will be stored in the website's server or database and has a website link to access it thereafter.

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  Год назад

      @@amankumarraj5090 so basically you are asking how to build a content management system.
      Not something anyone could answer in a comment

    • @amankumarraj5090
      @amankumarraj5090 Год назад

      @@SteveGriffith-Prof3ssorSt3v3 Where will I get the solution for this Sir? Would be great if you can make up a tutorial on it using Javascript. Earnestly looking forward to your approach on it.

  • @RemzM
    @RemzM Год назад

    Such a great explanation as always, thank you Steve. I still hope and believe we will see your big Vue course in the future 🙂

  • @derekfarealz
    @derekfarealz Год назад

    steve you are the gem of js. never stop!

  • @bxlbjorn
    @bxlbjorn Год назад

    finally, a fantastic explanation!!!

  • @arunkaiser
    @arunkaiser Год назад

    Please change the thumbnail design it is not much attractive