Currently browsing JavaScript
Learn modern JavaScript from the ground up with practical, example-driven tutorials. Covers core language concepts, browser APIs, and real-world techniques for building interactive web experiences. Whether you’re debugging a tricky snippet or leveling up your skills, you’ll find clear, hands-on guidance here.
Convert jQuery.get() to Vanilla JavaScript
In the latest iteration of my YouTube Playlist Player plugin, I decided to remove all jQuery dependencies. I replaced the…
How to Compare Version Numbers in JavaScript
The basic idea to make this comparison would be to get arrays of parts from the version numbers, and then compare pairs…
DragonflyJS – Vanilla JavaScript Drag and Drop
DragonflyJS is a tiny vanilla JavaScript library that enables sorting (dragging and dropping) functionality with zero dependencies.
How to Create a GDPR Modal Popup Using RoarJS
The script below will check for a localStorage variable, which is the explicit user consent. If the variable exists, the…
RoarJS – JavaScript Alert/Confirm Replacement
RoarJS is a wonderful, responsive, customisable, accessible (WAI-ARIA), zero-dependency, vanilla JavaScript alert/confirm replacement. RoarJS automatically centers itself on the page…
How to replace jQuery.ajax() with vanilla JavaScript in WordPress
In an effort to remove all jQuery dependency from one of my plugins, I decided to turn all jQuery.ajax() requests…
Useful JavaScript String Prototypes
This is a function to remove all double whitespaces and preceding line breaks. This is a function to replace all line…
How to Create an Internationalisation System Using JavaScript
Creating an i18n system in JavaScript can be tricky. The most popular option is to use global variables, but it…
Client-Side JavaScript Pagination
Server-side pagination is needed when you have to display hundreds of records. You may fetch results from a database using…
truthy and falsy in JavaScript
In JavaScript, any variable can be used in a logical context, such as the condition of an if statement or…
A JSON Overview
JavaScript Object Notation, or JSON, is a plain text data interchange format. It is based on a subset of the third…
Native Browser Support for JSON
JavaScript Object Notation, or JSON, is a text format used to represent JavaScript objects as strings. Like other text formats,…
Promises in JavaScript
Writing code in an async programming framework like node.js becomes super complex and unbearably ugly, superfast. You are dealing with…
Cutting Loose: Dynamic Namespacing in JavaScript
Most of the JavaScript libraries come wrapped in an easy to refer single object. The object acts as a namespace,…
Image Beacons
Using image beacons is one of those popular techniques that you would probably know about without knowing its name. The technique helps…
Understanding JavaScript Currying
I recently fully understood the concept of utilizing Currying in JavaScript. The core concept can be grasped from these references: Wikipedia entry on…
JavaScript Random String Generator
I needed a random string for various purposes. For example, to provide a unique ID to HTML elements via JavaScript.…
Giving Object Context to Function Calls
JavaScript has a dynamic object named this. By default, this equals to the global object container, so if we have…
Self Documenting Flexible Parameters
When managing function parameters, it’s often more maintainable to use an options object. This allows you to pass a single…
Use ‘this’ Keyword with setTimeout()
setTimeout() is a great help to many JavaScript developers. For example, you may wish to add a delay to allow…
Generate HTML List From JavaScript Array
Generate an HTML list based on the contents of a JavaScript array. By modifying the makeList() function to accept parameters…
Same-Origin AJAX Request Using Vanilla JavaScript
This JavaScript function will send an AJAX request - GET or POST - with no third-party dependencies. I find it…
How to Make an Iframe Responsive Using JavaScript
Stubborn iframes can be tamed using a simple JavaScript trick and a couple of code tweaks. Use the code below…
Pure JavaScript tabbing functionality with linkable tabs
This script shows you how to create vanilla JavaScript tabs anywhere, physically linkable without any external JavaScript library. 305 bytes…
JavaScript String Multiline Trim/Cleanup
This small JavaScript prototypes enhance the trim() function and allow for better trimming and/or replacing line breaks with commas (or…
JavaScript Credit Card Validation
This is a collection of JavaScript snippets to validate credit card details without requiring any library. Feel free to customise…