Socket
Book a DemoInstallSign in
Socket

@bicycle-codes/blur-image

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bicycle-codes/blur-image

A webcomponent that uses the 'blur up' technique

latest
Source
npmnpm
Version
0.0.6
Version published
Maintainers
0
Created
Source

blur image

tests types module semantic versioning dependencies license

Use the blur-up technique with images, as a web component.

This depends on having some inline base64 code for a small, blurry image. See @bicycle-codes/stringify for help with that.

install

npm i -S @bicycle-codes/blur-image

demonstration

See a demonstration here: substrate-system.github.io/blur-image.

[!TIP] Throttle the internet speed with the dev tools.

use

Import this module, then use the tag in your HTML. It should work with all contemporary image attributes.

bundler

Just import the module; it will call the global customElements.define function. Also, import the styles.

import '@bicycle-codes/blur-image'
import '@bicycle-codes/blur-image/style.css'

Then use the tag in your HTML:

<body>
    <blur-image
        src="/100.jpg"
        placeholder="data:image/jpeg;base64,/9j/2wBDAAYEBQY..."
    ></blur-image>
</body>

HTML

This package includes minified CSS and JS files, suitable for linking to directly from your HTML.

First make sure the files are accessible by your web server:

cp ./node_modules/@bicycle-codes/blur-image/dist/index.min.js ./public/blur-image.js
cp ./node_modules/@bicycle-codes/blur-image/dist/style.min.css ./public/blur-image.css

Then link to it in your HTML:

<head>
    <!-- include the style -->
    <link rel="stylesheet" href="/blur-image.css">
</head>

<body>
    <blur-image
        src="/100.jpg"
        placeholder="data:image/jpeg;base64,/9j/2wBDAAYEBQYFBAYGBQY..."
    ></blur-image>

    <!-- include the JS -->
    <script src="./blur-image.js"></script>
</body>

develop

Start a local dev server:

npm start

see also

Keywords

image

FAQs

Package last updated on 18 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts