Registry / web-framework / tlite
library0.1.9jsnpmunverified

Tlite is an extremely lightweight, dependency-free utility designed for displaying simple tooltips. Weighing in at approximately 800 bytes minified and gzipped, it focuses on minimal overhead. The package, currently at version 0.1.9, has seen no updates since 2018, indicating an abandoned or legacy status. It leverages event delegation for efficient operation on dynamic web pages and boasts broad browser compatibility, including IE9+ and modern browsers. A key differentiator is its small footprint and no external dependencies, contrasting with more feature-rich but heavier tooltip libraries. However, it lacks modern accessibility features, built-in HTML escaping for content, and advanced positioning/collision detection found in actively maintained alternatives.

npm install tlite
INSTALL
IMPORT
SIG · TLITE
T
tlite
web-frameworkjavascriptv0.1.9
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

tlite
import tlite from 'tlite';
const tlite = require('tlite');
While `tlite` can be imported via ESM in modern bundlers, for older projects or direct script inclusion, it's often available globally as `window.tlite`. The `require` syntax was common for Node.js environments if consumed as a CJS module.
tlite.show
import tlite from 'tlite'; tlite.show(targetElement, { grav: 's' });
require('tlite').show(targetElement);
The `show` method is a property of the main `tlite` function/object. Ensure the library is loaded and accessible before calling this method.
tlite.hide
import tlite from 'tlite'; tlite.hide(targetElement);
require('tlite').hide(targetElement);
Similar to `show`, `hide` is a method on the primary `tlite` export. It manually hides an active tooltip associated with a given element.

Demonstrates initializing Tlite with a selector function and manually showing/hiding a tooltip on a target element. Requires accompanying HTML elements to function.

import tlite from 'tlite'; // Add some HTML to your page (e.g., in a script tag or .html file) // <button class="my-tooltip-target" title="Hello from Tlite!">Hover for Tip</button> // <button class="my-tooltip-target" data-tlite="w" title="Another tip, positioned left!">Hover Here Too</button> // Initialize tlite to bind tooltips to elements with the class 'my-tooltip-target' // This will make any matching elements show a tooltip on hover based on their 'title' or 'data-tlite' attribute. // The selector function receives the element and should return true if tlite should manage it. const myTliteInstance = tlite(el => el.classList.contains('my-tooltip-target')); console.log('Tlite initialized for elements with class .my-tooltip-target'); // You can also manually show a tooltip, for example, on the first target after a delay const firstTarget = document.querySelector('.my-tooltip-target'); if (firstTarget) { setTimeout(() => { console.log('Manually showing tooltip on first target...'); tlite.show(firstTarget, { grav: 'n' }); // Show below the target setTimeout(() => { console.log('Manually hiding tooltip...'); tlite.hide(firstTarget); }, 3000); }, 2000); }
Debug
Known issues
gotchaTlite cannot display tooltips on 'contentless' HTML tags like `<img>`, `<input>`, or `<textarea>`. The tooltip is inserted as a child of the associated element, which is not possible for these tags.
fix
Wrap contentless tags in a parent element (e.g., `<span>` or `<div>`) and apply the tooltip binding to the wrapper element instead.
affects: >=0.1.0
breakingTlite does not escape tooltip text. If you use user-provided input for tooltip content (e.g., via `title` or `data-tlite` attributes), it is vulnerable to Cross-Site Scripting (XSS) attacks.
fix
Always sanitize or escape any user-generated content before rendering it within tooltip attributes (e.g., `element.setAttribute('title', escapeHTML(userInput))`) to prevent malicious script injection.
affects: >=0.1.0
gotchaWhen manually controlling tooltip visibility with `tlite.show()` for events other than hover (e.g., focus, click), Tlite does not automatically reposition the tooltip on window resize. This can lead to tooltips appearing in incorrect positions.
fix
Implement custom event listeners for window `resize` events. In your resize handler, either reposition the tooltip using `tlite.show(target, { grav: '...' })` or hide it with `tlite.hide(target)`.
affects: >=0.1.0
gotchaTooltips displayed within HTML tables might experience improper positioning due to table layout constraints. Tlite may not correctly calculate offsets in certain table structures.
fix
Apply the `tlite-table` class to the `<table>` element containing the tooltip target to improve positioning accuracy.
affects: >=0.1.0
Errors
Common errors & fixes
ReferenceError: tlite is not defined
The `tlite` script was not loaded, or the module was not imported correctly, or it's being accessed before the DOM is ready.
fix
Ensure `tlite.js` is included in your HTML `<script>` tag before your application script, or `import tlite from 'tlite';` at the top of your module. If using it with a global script, place script tags appropriately for execution order.
Tooltip not appearing on <img>, <input>, or <textarea> elements.
Tlite injects the tooltip as a child element, which is not possible for 'contentless' (void) HTML tags.
fix
Wrap the `<img>` or `<input>` element in a `<span>` or `<div>` and apply the `title` attribute or `data-tlite` to the wrapper element. Then, initialize tlite to target the wrapper.
Unwanted HTML or JavaScript executing within a tooltip.
User-supplied content was placed into a tooltip's `title` or `data-tlite` attribute without proper escaping, leading to a Cross-Site Scripting (XSS) vulnerability.
fix
Before setting any attribute used by tlite (like `title` or `data-tlite`) with user-generated input, ensure the input is thoroughly sanitized or HTML-escaped on the server-side or client-side (e.g., using a library like `DOMPurify`).
Tooltip position shifts or is incorrect after window resize or orientation change.
If `tlite.show()` is used for manually triggered tooltips, Tlite does not automatically re-calculate position on window resizing.
fix
Add a JavaScript event listener for the `window.onresize` event. Inside this handler, either explicitly call `tlite.hide(targetElement)` to close the tooltip or re-call `tlite.show(targetElement, { grav: '...' })` with updated positioning logic.
Upgrade
Version history
0.1.9latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
tlite — npm install tlite · libregistry