Israel2024
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Introduction **Brief Overview of Web Component Libraries** ![webcomponent](https://hackmd.io/_uploads/By5_VBNT6.png) Web component libraries for the web consist of pre-made, reusable elements designed for integration across web applications. They offer a standardized collection of UI components, streamlining development and ensuring consistency throughout the application. **Brief introduction to Stencil and LitElement** [Stencil](https://stenciljs.com/), a compiler, generates Web Components, particularly Custom Elements, by amalgamating the best concepts from popular frameworks into a single, user-friendly build-time tool. Stencil facilitates the creation of standards-compliant Web Components, leveraging TypeScript, JSX, and CSS for the development of top-tier component libraries. [LitElement](https://https://lit.dev/) serves as a straightforward base class for swiftly and efficiently crafting web components, compatible with any web page and framework. **Benefits of choosing the right component library** * The right component libraries give you a standardized design for your product and services. * The role of the design teams is made easier when they have easy access to all of the fundamental user interface elements. They only need to select the design elements and make the necessary modifications. * Component libraries present an opportunity to promote scalability, standardize development, lessen code duplication, and enhance team cooperation. * Component libraries also enhance user experience consistency which is an important factor when building a product or service. # Stencil **Brief overview of Stencil** Functions and design goals Its design goals align with a couple of approaches: **Pattern:** A pattern is a subjective arrangement of parts. Several elements are frequently blended to produce a uniform user experience (UX). **Code Implementations and Design Artifacts:** Designers can produce design artifacts that depict user interface operations by utilizing the elements, patterns, and visual language of the design system. **Visual Communication:** A unified company brand makes a company more valuable in the eyes of the consumer. This means that different elements of the visual style, such as colors, typography, and icons, must be defined in the context of design systems. Compiler-based approach Stencil uses three compiler-based approaches: * CLI API The CLI API can be found at `@stencil/core/cli` and run by `bin/stencil.` These are examples of the core cli api: * `createNodeLogger()` * `createNodeSystem()` * `parseFlags()` * `run()` * `runTask()` * Compiler API The compiler API can be found at `@stencil/core/compiler/stencil.js.` This module can work within a NodeJS environment, web worker, and browser window. The `stencil.min.js` file is also provided and recommended when used within a browser. These are examples of compiler api: * `transpile()` * `transpileSync()` * `createCompiler()` * `createSystem()` * `loadConfig()` * Dev Server API The CLI API can be found at `@stencil/core/dev-server`. This only has one example: * `start()` *Read Further in the link provided below* [Stencil Compiler API](https://stenciljs.com/docs/cli-api) Examples of web component libraries built with stencil ![component libraries built with stencil](https://hackmd.io/_uploads/SJAU7OVTp.png) **Important Features** Compiler optimizations for performance: With the standard component model as the common input, the compiler can continue to achieve optimizations without needing full rewrites of the components. Multiple reusable components: Stencil supports the reusability of frontend components across a project, product, or service which is the backbone of a great product design system with enhanced developer experience. Platform-agnostic components: Stencil further empowers their components to be platform-agnostic whereby you can use them in other frameworks such as React, Angular, Vue, and other frontend frameworks. **Use Cases** Large-scale applications: Stencil is a library that scales, which implies that it can be used on larger projects because of the compiler optimization that allows it to build fast with minified style output. Cross-framework compatibility: Stencil is a platform-agnostic library as I have mentioned above with its ability to be used across frontend frameworks. Stencil provides a starter kit to seamlessly transition into frontend frameworks. Third-party libraries: Stencil is a library that can be used to build other libraries, which means stencil has been used to build high-quality component libraries that are efficient and well-optimized for their specified purposes. **Pros and Cons** Pros: Efficiency: Stencil is an agnostic platform that prioritizes build-time tools while considering its ability to craft high-quality component libraries. Performance: Stencil is traditionally used to compile many components into an app, and each component comes with its compartmentalized style. Versatility: The ability to use stencil to build libraries and design systems with any frontend framework such as React, Angular, and Vue shows its usage flexibility, which is one of the reasons it was built to solve the cross-platform barrier by using one library across all. Cons: Complexity: Stencil is a made-easy web component library, any concept, programming language, or library has its own rules, syntax, and concepts. learning curves: When building a library with stencil you have to be firstly familiar with the concept of building a design system which shows you've been consistent with that concept, that will be a head-start diving into the stencil docs to build a design system or library as preferred. --- # LitElement **Brief overview of LitElement** Lit is a revolutionary library designed for crafting rapid and lightweight web components. Serving as the cornerstone of component development, Lit offers reactive state management, scoped styling, and a concise, declarative template structure. ### Function Philosophy: **Interoperability**: LitElement is designed to seamlessly integrate with existing web technologies and frameworks. It leverages the power of web components, ensuring compatibility across various environments and frameworks. **Reactivity**: LitElement offers reactive state management, allowing components to automatically re-render when the underlying data changes. This ensures a smooth and responsive user experience. **Scoped Styles**: LitElement provides scoped styling by default, preventing style conflicts and ensuring encapsulation within components. This enhances maintainability and reduces the risk of unintended style changes. ### Design Philosophy: **Simplicity**: LitElement prioritizes simplicity by building upon web standards and adding only essential features for efficient component development. **Performance**: LitElement is designed for high performance, with efficient updates that optimize rendering speed. **Lightweight**: LitElement maintains a small footprint, with a minimal bundle size of around 5 KB (minified and compressed). Lightweight nature **Small Bundle Size**: LitElement is designed to be compact, with a minimal footprint. When minified and compressed, the core library typically weighs around 5 KB. **Efficient Resource Management**: LitElement optimizes resource usage by focusing on essential features and minimizing unnecessary overhead. **Lean Codebase**: The codebase of LitElement is streamlined and concise, prioritizing clarity and efficiency. Examples of web component libraries built with litElement ![litelementlibraries](https://hackmd.io/_uploads/SJugwltTa.png) **Important Features** Developer-friendly syntax: **Declarative Templates**: LitElement uses a declarative template system, making it easy to define component structure using HTML-like syntax. **Expressive Tagged Template Literals**: LitElement leverages JavaScript-tagged template literals to create expressive and dynamic templates. **Reactive Properties with Decorators**: The use of decorators like `@property` and `@state` enables developers to define reactive properties with a clean and concise syntax. **Scoped Styles by Default**: LitElement automatically scopes styles, eliminating global style conflicts. Use of Modern JavaScript Features: **ES6 and Beyond**: LitElement utilizes ECMAScript 6 (ES6) and later features, allowing developers to take advantage of modern language enhancements. **Decorators for Metadata Annotation**: LitElement utilizes decorators, such as `@customElement` and `@property`, for metadata annotation. **Module System Support**: LitElement is designed to work seamlessly with JavaScript modules, facilitating modular code organization. **TypeScript Support**: While not explicitly mentioned in the provided content, it's worth noting that LitElement supports TypeScript. **Use Cases** Custom Elements without Much Overhead: LitElement is an ideal choice for creating custom elements with minimal overhead. LitElement is well-suited for smaller projects and random development tasks where simplicity and agility are paramount. **Pros and Cons** Pros: **Basic, Quick, and Easy Setup:** LitElement excels in providing a straightforward and hassle-free setup for web component development. **Developer Experience:** LitElement enhances the overall developer experience by offering a clean and expressive syntax. Cons: **May Lack Important and Advanced Optimizations:** While LitElement excels in simplicity and ease of use, it may lack some of the advanced optimizations found in larger frameworks. **Projects Are Limited:** LitElement is particularly well-suited for smaller projects, prototypes, and custom element development. --- # Comparison ### Performance **LitElement's Runtime Overhead:** LitElement, being a runtime library, has a minimal runtime overhead. Its core functionality revolves around managing reactive state, rendering templates, and handling component lifecycle events. Since LitElement operates primarily at runtime, its performance depends on factors such as the complexity of component templates, the frequency of state changes, and the efficiency of rendering algorithms. ### Stencil's Compiler Optimizations: **Build-time Optimizations**: Stencil's compiler optimizes code during the build process, reducing the size of generated JavaScript bundles and improving loading times. **Runtime Efficiency**: Stencil-generated components are designed to be highly efficient at runtime. The compiler optimizes rendering algorithms, updates to the DOM, and event handling mechanisms to minimize latency and improve responsiveness. **Performance Comparison:** In terms of performance, both LitElement and Stencil offer efficient solutions for web component development. LitElement's runtime overhead is minimal, making it suitable for lightweight components and applications where simplicity and ease of use are priorities. ### Versatility and Flexibility **LitElement's Focus on Simplicity:** **Ease of Use**: LitElement offers a straightforward and intuitive API that simplifies web component development. Developers can quickly scaffold components, define reactive properties, and create declarative templates using familiar HTML-like syntax. **Minimalistic Approach**: LitElement maintains a minimalistic approach to web component development, focusing on essential features while minimizing complexity and boilerplate code. **Interoperability**: LitElement embraces web standards and interoperability, making it compatible with a wide range of frameworks, libraries, and platforms. **Stencil's Platform-Agnostic Components:** **Cross-Framework Compatibility**: Stencil components are designed to work seamlessly with popular front-end frameworks such as React, Angular, and Vue. **Flexibility in Framework Selection**: Stencil's platform-agnostic components give developers the flexibility to choose the frontend framework that best suits their project requirements and preferences. **Ecosystem Integration**: Stencil's platform-agnostic components integrate seamlessly with existing front-end ecosystems and tooling. ### Comparison: **Simplicity vs. Cross-Framework Compatibility**: LitElement's focus on simplicity makes it easy for developers to get started with web component development, but its compatibility is primarily limited to web standards and the Lit ecosystem. On the other hand, Stencil's platform-agnostic components offer cross-framework compatibility, allowing developers to use Stencil components across different front-end frameworks and platforms. **Minimalistic Approach vs. Flexibility in Framework Selection**: LitElement's minimalistic approach prioritizes essential features and ease of use, making it suitable for a wide range of projects and use cases. However, its compatibility is primarily limited to web standards and the Lit ecosystem. In contrast, Stencil's platform-agnostic components provide flexibility in framework selection, allowing developers to choose the front-end framework that best suits their project requirements and preferences while leveraging Stencil components for enhanced functionality and interoperability. ### Learning Curve **Stencil's Difficulty Due to Compiler:** **The Complexity of Compiler Concepts**: Stencil's compiler introduces additional complexity to the development process compared to traditional runtime frameworks like LitElement. **Build-Time Considerations**: With Stencil, developers need to familiarize themselves with build-time considerations such as configuring the compiler, optimizing build scripts, and understanding how code transformations impact the final output. **LitElement's Well-Known JavaScript Features:** **Familiarity with JavaScript**: LitElement leverages modern JavaScript features such as ES6 classes, decorators, and template literals, which are widely used and understood by JavaScript developers. **Declarative Templating**: LitElement's use of declarative templating with HTML-like syntax simplifies the process of defining component structure and behavior. ### Speed Of Development **Stencil's Potential Time Investment for Optimization:** Optimization Overhead: Stencil's compiler-based approach offers extensive optimization capabilities for web component development. Build-Time Considerations: Stencil's build process involves analyzing component code, performing static analysis, and generating optimized output. **LitElement's Quicker and Easier Development Process:** Minimal Setup and Configuration: LitElement offers a streamlined development experience with minimal setup and configuration required. Immediate Feedback and Iteration: LitElement's runtime-focused approach enables developers to receive immediate feedback during development. --- # Decision Factors ** Developer Experience and Familiarity:** LitElement: Offers a developer-friendly syntax with well-known JavaScript features, making it accessible to developers familiar with modern web development practices. Stencil: Requires familiarity with compiler-based tools and build-time optimizations, which may pose a steeper learning curve for developers new to compiler-driven development workflows. **Performance Requirements:** LitElement: Provides efficient updates and rendering mechanisms, suitable for projects where performance optimization is essential but may lack some advanced optimizations offered by Stencil. Stencil: Employs compiler optimizations for enhanced performance, making it well-suited for large-scale applications and projects with strict performance requirements. **Ability to Work with Other Frameworks:** LitElement: Integrates seamlessly with existing web technologies and frameworks, allowing components to be used across different environments without significant modification. Stencil: Offers platform-agnostic components that can be easily integrated into various frontend frameworks, providing flexibility and interoperability across different development ecosystems. **Project Scope and Size:** LitElement: Ideal for smaller projects, prototypes, and custom element development due to its quicker and easier development process, minimal setup, and straightforward syntax. Stencil: Suited for larger projects and component libraries where optimization, scalability, and cross-platform compatibility are paramount, despite potentially requiring more time investment for optimization and configuration. **Maintenance and Updates:** LitElement: Benefits from a vibrant community, extensive documentation, and simplified debugging process, facilitating maintenance and updates over time. Stencil: Offers comprehensive optimization capabilities and long-term scalability, but may require ongoing maintenance and updates to keep up with evolving compiler features and best practices. # Conclusion **Summary of the Important Features of Both Web Component Libraries:** **LitElement:** - Developer-friendly syntax with modern JavaScript features. - Reactive properties and scoped styles for simplified state management and styling. **Stencil:** - Compiler optimizations for enhanced performance and scalability. - Platform-agnostic components for seamless integration with various frameworks. **Importance of Aligning Library Choice with Project Goals:** Selecting the appropriate web component library is crucial for achieving project success and meeting development objectives. Consider factors such as performance requirements, project scope, maintenance needs, and developer familiarity when choosing between LitElement and Stencil. **Encouraging Developers to Evaluate Their Needs Before Making a Decision:** Developers are encouraged to assess their project requirements, team capabilities, and development preferences before selecting a web component library. Conduct thorough research, explore documentation, and evaluate the strengths and limitations of each library to make an informed decision. In conclusion, choosing between LitElement and Stencil requires careful consideration of project goals, development priorities, and technical requirements. By understanding the unique features and capabilities of each library and aligning them with project needs, developers can leverage web component technology to build scalable, efficient, and maintainable web applications.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully