https://github.com/liquidlight/frontend-utils
Frontend utils
https://github.com/liquidlight/frontend-utils
Last synced: 5 months ago
JSON representation
Frontend utils
- Host: GitHub
- URL: https://github.com/liquidlight/frontend-utils
- Owner: liquidlight
- Created: 2026-02-11T10:31:36.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2026-02-11T12:38:54.000Z (5 months ago)
- Last Synced: 2026-02-15T16:40:29.661Z (5 months ago)
- Language: JavaScript
- Size: 32.2 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Utils
A collection of JavaScript utilities and helper functions
## Labels
**Returns**
- `l` - gets the current document language
- `labels` - an object with translations
**Usage**
```javascript
import {l, labels} from '@packages/utils';
// Extend the _labels_
$.extend(true, labels, {
en: {
'cookify.message': `This site uses cookies.`
},
pt: {
'cookify.message': `Este site usa cookies.`
}
})
const cookieBanner = $(`
`);
```
## Debounce
An example of sticky navigation on scroll with `debounce` function
**Usage**
```javascript
import { debounce } from '@packages/utils';
(() => {
const header = $('.siteHeader'),
headerHeight = header.outerHeight(true);
window.addEventListener('scroll', debounce(function() {
if ($(this).scrollTop() > headerHeight) {
header.addClass('isFixed');
} else {
header.removeClass('isFixed');
}
}, 200));
})();
```
## Migrate to version 2
- `docReady()` was renamed to `documentReady()`
- `url-get-parameters` function was removed. Use the native `URLSearchParams()` - see [URLSearchParams](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) on MDN
- `guid-generator` was also removed in favour of native [Crypto](https://developer.mozilla.org/en-US/docs/Web/API/Crypto) interface eg. `const randomId = crypto.getRandomValues(new Uint32Array(1))[0]`