Skip to content
💲 Act on jQuery elements only once.
JavaScript HTML
Branch: master
Clone or download
RobLoach Merge pull request #104 from RobLoach/greenkeeper/uglify-js-3.8.0
Update uglify-js to the latest version 🚀
Latest commit 9e50e70 Feb 18, 2020

jQuery Once NPM version

Build Status NPM downloads Dependency Status Greenkeeper badge

Act on jQuery elements only once.

Filters out all elements that had the same filter applied on them before. It can be used to ensure that a function is only applied once to an element.


Method Installation
npm npm install jquery-once --save
Composer composer require robloach/jquery-once
Bower bower install jquery-once
Component component install RobLoach/jquery-once
jsDelivr //
cdnjs //


See the API documentation for more information on how to use jQuery Once.

// The following will change the color of each paragraph to red, just once
// for the "changecolor" key.
$('p').once('changecolor').css('color', 'red');

// .once() will return a set of elements that yet to have the once ID
// associated with them. You can return to the original collection set by
// using .end().
    .css("color", "blue")
  .css("color", "red");

// To execute a function on the once set, you can use jQuery's each().
$('div.calendar').once().each(function() {
  // Since there is no once ID provided here, the key will be "once".


  1. Ensure you are using node >= 4:
node --version
  1. Install dependencies through npm:
npm install
  1. Check coding style standard, and automated testing:
npm test
  1. Build jquery.once.min.js with:
npm run build
  1. Update API documentation:
npm run docs
  1. Tag and publish the new versions to npm with Semantic Versioning:
git add -A
git commit -m "2.1.2"
git tag 2.1.2
git push origin 2.1.2
npm publish


It is possible to run tests through Docker Compose:

docker-compose up

Change Log

Discover the change history by heading on over to the file.


Dual licensed under:

Copyright © Rob Loach

You can’t perform that action at this time.