DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations

Web Components a New Perspective to Web Development

This new concept it was created jointly by Firefox and Google and promises change to some paradigms. Learn more here!

Rafael Salerno user avatar by
Rafael Salerno
·
Sep. 27, 16 · Opinion
Like (4)
Save
Tweet
Share
7.50K Views

Join the DZone community and get the full member experience.

Join For Free

This new concept it was created jointly by Firefox and Google and promises change to some paradigms.

Image title

"The component model for the Web called Web Components consists of four pieces designed to be used together to let web application authors define widgets with a level of visual richness not possible with CSS alone, and ease of composition and reuse not possible with script libraries today."

Web Components consist of 4 proposals: 

1. Templates

Templates are parts of DOM that could be reusable, and this Templates will be append to the DOM. That means <img> sources are not downloaded, scripts are not executed until necessary, saving on bandwidth and processing ,and also the script necessary to execute this component in this example querySelector is hidden on the Template to avoid influencing in the other part of the page.

Demo: http://jsfiddle.net/warpech/7y6kp/

2.Shadow DOM

Shadow DOM provides encapsulation to markup and style, for example, a <video> tag , this tag has many scripts to provide functionality . Each of those controls is implemented as a <div> inside of the <video> tag that is actually not accessible for the scripts on the page but is rendered on users' screen.

Shadow DOM is a tool that provides to web developer create own component like tag <video> or <img>.

Demo: http://jsfiddle.net/Wnsf6/

3.Custom Elements 

Custom Elements can react to the DOM lifecycle events. That enables them to have a certain behavior when they are added to DOM, their attributes change or they are removed from DOM.

Is possibility to create own first-class DOM members (fist-class DOM could be considered <div>,<p>,<br> etc ... ).

Demo: http://jsfiddle.net/7y6kp/7/

4.Imports 

Imports load external resources, such as Templates or Custom Elements. Imported HTML files can contain templates, stylesheets, and scripts. They get executed when the import is loaded.

Why do I care about this? 

  • You are a HTM user, this will help you do more advanced this easily.
  • You are a front end dev, you want to reuse components across pages.
  • You build single pages apps and want a better way to organize things.
  • You are interested in the direction that the web platform is heading.

Unfortunately, these components were available just to Google Chrome Canary or for test in jsFiddle.

But is possible use Polymer or Component Kitchen to use web components in another browser.

Here is a good presentation.

Here is a site with discussions and best-practices:  http://webcomponents.org

Web application Web development

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Fixing Bottlenecks in Your Microservices App Flows
  • Microservices 101: Transactional Outbox and Inbox
  • Seamless Integration of Azure Functions With SQL Server: A Developer's Perspective
  • How To Select Multiple Checkboxes in Selenium WebDriver Using Java

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: