How to install lit-html

Created

lit-html lets you write HTML templates in JavaScript, then efficiently render and re-render those templates together with data to create and update DOM.

lit-html is an HTML templating library made by the Polymer team. This library stands out for being simple, very small, extremely efficient in terms of speed and use of resources, and all this is because it is based on web standards.

A very important point to note is that lit-html doesn't define any component model and therefore can be used in any project with other frameworks or libraries.

Installation

You can download the latest version of lit-html from the GitHub releases or use a lit-html CDN.

Cloning a repository

You can clone a repository from GitHub.com to your local computer.
Cloning with HTTPS URLs
git clone https://github.com/Polymer/lit-html.git
Cloning with SSH URLs
git clone [email protected]:Polymer/lit-html.git
Cloning with GitHub CLI
gh repo clone Polymer/lit-html

Install via NPM package

Run the following command to locally install the package and its dependencies with NPM.
Downloading and installing packages locally
npm i lit
npm install lit
yarn add lit
Downloading and installing packages globally
npm i -g lit
yarn global add lit
Install Specific Version of a Package
npm install [email protected]
Bower
bower install lit

Example

lit-html - templates are plain JavaScript and combine the familiarity of writing HTML with the power of JavaScript. lit-html takes care of efficiently rendering templates to DOM, including efficiently updating the DOM with new values.

import {html, render} from 'lit-html';

// This is a lit-html template function. It returns a lit-html template.
const helloTemplate = (name) => html`
Hello ${name}!
`; // This renders
Hello Steve!
to the document body render(helloTemplate('Steve'), document.body); // This updates to
Hello Kevin!
, but only updates the ${name} part render(helloTemplate('Kevin'), document.body);

Polymer is an open-source JavaScript library for building web applications using Web Components. The library is being developed by Google developers and contributors on GitHub. Modern design principles are implemented as a separate project using Google's Material Design design principles. Polymer is used by a number of Google services and websites, including the redesigned YouTube, YouTube Gaming, the redesigned Google Earth, Google I/O websites, Google Play Music, redesign of Google Sites and Allo for web.