This toolkit is designed to help you creating A/B tests. Have fun using it!
Questions or feedback?
team@codeschmiede.de
$ npm install codeschmiede-toolkit
$ yarn add codeschmiede-toolkit
import { waitFor } from 'codeschmiede-toolkit';
waitFor('#example', (example) => {
// do something...
});
The waitFor
function is using document.querySelector() internally.
waitFor('.example', (example) => {
// do something...
});
waitFor
is also working with a function as a selector.
waitFor(
() => return window.example === true,
() => {
// do something...
}
);
(async () => {
const body = await waitForSync("body");
// do something...
})();
The ready
function is using the DOMContentLoaded Event.
ready(() => {
// do something...
});
The qs
function is just a wrapper for document.querySelector().
An Element object representing the first element in the document that matches the specified set of CSS selectors, or null is returned if there are no matches.
const node = qs('#example');
// do something...
node.textContent = 'My new text...';
The qsa
function is just a wrapper for document.querySelectorAll().
A non-live NodeList containing one Element object for each element that matches at least one of the specified selectors or an empty NodeList in case of no matches.
const nodeList = qsa('.example');
// do something...
[...nodeList].forEach(item => { ... });
The addClass
function is just a wrapper for element.classList.add.
addClass(element, 'classNameToAdd');
The removeClass
function is just a wrapper for element.classList.remove.
removeClass(element, 'classNameToAdd');
const isMobileDevice = isMobile();
if(isMobileDevice){
// do something for mobile traffic...
} else {
// do something for desktop traffic...
}
const browserWidth = getWidth();
// do something...
const myCookkie = getCookie('myCookie');
// do something...
setCookie ('myCookie', 'myValue', 90);
// do something...
Copyright (c) 2024 codeSchmiede GmbH & Co. KG.
Licensed under The MIT License (MIT).