Welcome to scant’s documentation!

A very minimalistic javascript library.

scant /skant/

adjective: scant

  1. barely sufficient or adequate.

“companies with scant regard for the safety of future generations”

synonyms: little, little or no, minimal, hardly (any), limited, negligible, barely sufficient, meager

antonyms: abundant, ample, sufficient barely amounting to a specified number or quantity.

verb: scant; 3rd person present: scants; past tense: scanted; past participle: scanted; gerund or present participle: scanting

  1. provide grudgingly or in insufficient amounts.
“he does not scant his attention to the later writings”


<script type="text/javascript" src="//path/to/scant.min.js"></script>
<script type="text/javascript">
  // window.Scant === window.$
  // window.$ is only made available is $ is not already registered

    var $elm = $('.selector');
    $elm.on('click', '.child', function(evt){

      var data = $('form').serialize();
        url: '/end-point',
        data: JSON.stringify(data),
        dataType: 'application/json',
        responseType: 'json',
      }, function(err, request){
        if(err || ~request.response){
          alert('oh no, something went wrong');
        } else {
          alert('go a good response back');

API Documentation

$ Object


Main entry point for creating an instance of scant().

  • selector (string|NodeElement|HTMLElement) – Either a string css selector to use to fetch elements on the page or an element to wrap in scant()

an instance of scant().

$.util.extend(target, source)

Helper method to copy properties from one Object over to another

  • target (Object) – Object to copy properties onto
  • source (Object) – Object to copy properties from

a copy of target with all of sources‘s properties copied to it

$.util.inherits(parent, child)

Helper method to ensure that child‘s prototype inherits from parent‘s

  • parent (function) – The parent class to inherit from
  • child (function) – The child class to inherit to



The prototype for scant() exposed, useful for extending scant().

$.fn.hide = function(){
  // "this" refers to the instance of scant
    elm.style.display = 'none';

$.ajax(options, callback)

Wrapper around making XMLHttpRequest’s.

// default options to $.ajax
var defaultAjaxOptions = {
    // url to fetch
    url: null,
    // http method to use
    method: 'GET',
    // additional headers e.g. {'X-Token': 'token'}
    headers: {},
    // data to send
    data: null,
    // this gets set as 'Content-Type' header with request
    dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
    // an optional function(request) to call before sending the request,
    // useful to make customizations to the XMLHttpRequest object before sending
    beforeSend: null,
    // the response type expected back
    responseType: '',
  • options (Object) – Object of options to override. url is required
  • callback (function) – function(err, request) will get called when the request has finished (success or fail). err will be true if the request failed, null otherwise request will be the XMLHttpRequest() object used for the request.


$.on(eventName, [selector, ]handler)

Function for event delegation. This method will add handler as an event handler on body, optionally filtering based on the selector provided.

  • eventName (string) – The event to bind (e.g. ‘click’, ‘submit’, etc)
  • selector (string) – Optional parameter, a css selector used to filter events
  • handler (function) – The handler to bind for the event



Function used to add a handler when the page has finished loaded (‘DOMContentLoaded’).

  • handler (function) – The handler to invoke when ‘DOMContentLoaded’


scant Class

class scant([dom][, selector])

The scant class inherits from Array and properties of an Array are available (although forEach is shimmed in if it is not supported by the browser).

  • dom (Object) – dom is either an Array of elements or the result of calling document.querySelectorAll with a selector
  • selector (string) – The selector used to fetch dom.

Method used to find all children matching selector beloning to the elements stored in this instance of scant.

  • selector (string) – A css selector to use to match elements.


scant.on(eventName, [selector, ]handler)

This method is the same as $.on() except the handler is bound to every node stored in this instance of scant as opposed to binding to body.

  • eventName (string) – The event to bind to (e.g. ‘click’, ‘submit’, etc)
  • selector (string) – A css selector used to filter the events by
  • handler (function) – The handler to call for each event.



Method used to serialize the data for elements stored in this instance of scant. Most useful for fetching the data from form elements. This method gets the name/value pairs for all form elements (creating an array when the same name is present multiple times) as well as appending element data attributes.

  • elm (Object) – This parameter is mostly used internally to this function when making recursive calls for serializing the data, but can be a single dom element to serialize.


Indices and tables

Table Of Contents

This Page