How can I redirect the page to HTTPS in JavaScript?
Learn how to redirect the page to HTTPS if it's currently in HTTP.
The JavaScript snippet collection contains a wide variety of ES6 helper functions. Browser snippets include helper functions for selecting, traversing, and manipulating DOM elements, while general-purpose helpers can be found in the JavaScript snippet collection.
Learn how to redirect the page to HTTPS if it's currently in HTTP.
Determine if the current JavaScript environment is Node.js or a browser.
There are many ways to create empty links, some more appropriate than others. Learn how to best handle empty links with this quick tip.
CORS (Cross-Origin Resource Sharing) trips up many developers, but it's pretty easy to wrap your head around.
Learn a simple way to get the browser's current URL in JavaScript.
Finds the anchor node closest to the given node
, if any.
Scroll listeners can easily become a performance bottleneck for your web application. Here's how to fix that.
Increase your JavaScript code's performance when working with the DOM by leveraging this simple trick.
Learn how to check if an element is visible in the browser's viewport, using this simple technique.
Learn how to work with HTML element classes in JavaScript, from simple class checks to adding, removing and toggling classes.
Ever wanted to create your own jquery-like query selector shorthand? Here's how!
Calculate the coordinates of the current scroll position in the browser window using JavaScript.
Checks if the given string is an absolute URL.
Finds the closest matching node starting at the given node
.
Smooth-scrolls to the top of the page.
Here's a quick and easy way to select the currently focused DOM element in JavaScript.
Finds the distance from a given element to the top of the document.
Learn how to insert an HTML string before or after the start of a specified element using JavaScript.
Redirects to a specified URL.
Removes an element from the DOM.
Creates an element from a string without appending it to the document.
Checks if the parent
element contains the child
element.
Gets the currently selected text.
Check if localStorage
or sessionStorage
is enabled in the browser, using a simple JavaScript function.