A tiny, lightning fast jQuery-like library for modern browsers.

Overview

Sprint.js

Sprint is a high-performance, 5KB (gzipped) DOM library for modern browsers. Sprint notably shines on bandwidth and resource constrained devices such as phones and tablets.

Sprint has a familiar, jQuery-like chainable API:

$("div").addClass("new").append("<p>Hi Sprint</p>");

Philosophy

Sprint is an alternative—not a replacement—for jQuery. jQuery offers more features, handles more edge cases and supports more browsers. Sprint is just a thin layer making the DOM friendlier without sacrificing on performance.

Performance

Sprint relies on newer APIs supported by modern browsers (read: IE10+) and optimizes a bunch of other things in order to provide you with fast DOM operations.

Here are a few performance tests of some popular methods (Chrome 42, OS X 10.10.3) :

.add()

jsperf results

→ View on jsperf

.attr()

jsperf results

→ View on jsperf

.css()

jsperf results

→ View on jsperf

.has()

jsperf results

→ View on jsperf

.map()

jsperf results

→ View on jsperf

.next()

jsperf results

→ View on jsperf

.not()

jsperf results

→ View on jsperf

.parents()

jsperf results

→ View on jsperf

.position()

jsperf results

→ View on jsperf

.slice()

jsperf results

→ View on jsperf

.text()

jsperf results

→ View on jsperf

Thanks to its reduced feature set, Sprint is also a lot faster to parse and execute (about 40 times faster than jQuery).

API

The methods supported by Sprint are, for the most part, identical to jQuery's. The few small differences with jQuery are explained below. If nothing is mentioned, you can assume jQuery's documentation applies.

Comments
  • How to implement with jQuery?

    How to implement with jQuery?

    Maybe I'm asking a dumb question, I see that this is an "alternative" not a replacement, but I can't find any proper info on how to deal with jQuery and Sprint together on the same page. So basically, how can I use Sprint along with jQuery? I have some plugins with jQuery dependancy, how should I proceed to implement Sprint? Since the same API is used will there be conflicts if both scripts are present?

    opened by GlassGruber 12
  • alert not showing

    alert not showing

    Nice library indeed! Just noticed this issue, the code below is not showing the alert as its should show the alert from the function of the click event of the button.

    $(document).ready(function() {
          $( 'body' ).append( "<input type='button' id='alertdiv' value='Text of Alert Button' style='cursor:pointer' />" );
          $('#alertdiv').click(function() {alert("Hello, world!");});
    });
    
    opened by football-fastball 4
  • couple gotchas with css

    couple gotchas with css

    Cool library. :+1:

    Just skimming the css() function and noticed a couple pitfalls that you may want to mention in the docs.

    • there is no vendor prefixing on css()
    • case is not normalized; so element.css('backgroundColor') !== element.css('background-color')
    • this also means css('zIndex', 0) is treated as pixels, css('z-index', 0) is treated as a number
    • does not handle cssFloat edge case
    opened by mattdesl 3
  • Avoid a conflict with jQuery

    Avoid a conflict with jQuery "$", using "S" as Sprint.js symbol.

    I created extension library of Sprint.js for Rails Asset Pipeline, Sprint-rails.

    I realized "$" conflicts with the default rails JS-library setting(jquery-rails and asset pipeline for that), so when I use this with other existing libraries, I'd like to change the notation to use Sprint.js from $.

    opened by timakin 2
  • No selector support for .on/.off?

    No selector support for .on/.off?

    For dynamically loaded/drawn content, it's required to write code like:

    $(document).off('event', 'selector').on('event', 'selector', function (event) { 
     ... 
    })
    

    no?

    How else could Sprint currently be used?

    opened by brandonros 2
  • created a bower package of SprintJS

    created a bower package of SprintJS

    @bendc can you check this out? I made a bower package of sprint.js, perhaps you want to see if its suitable for merge or if there is anything needed to be changed.

    opened by albatros2ko 2
  • All jspref benchmarks fail to run with https

    All jspref benchmarks fail to run with https

    Since your sprintjs.com has no SSL support (it seems), the protocol-relative url //sprintjs.com/prod will just fail on https://jsperf.com/, which is the default if you have HTTPS Everywhere for Chrome. Like this:

    image

    This is not an issue with sprint per se, but you may want to revise the jspref snippets to eliminate any confusion.

    Anyway, great library! :+1:

    opened by phanan 1
  • Implement CommonJS + AMD + Browser Globals pattern (Fixes #3)

    Implement CommonJS + AMD + Browser Globals pattern (Fixes #3)

    This commit modifies the function form of the module to implement a pattern, that loads the module in CommonJS, AMD and Browser Globals. Therefore it tackles #3. Sprint can now be loaded in any CommonJS-like environment, AMD-like environments and regularly in the browser.

    • Call the function wrapper with the global this
    • Make Sprint a local variable
    • Export Sprint for AMD and CommonJS
    • Set this.$ and this.Sprint for browsers
    opened by kitten 1
  • Modularize?

    Modularize?

    Maybe it should be split up into tiny modules so a user can require whatever she wants and bundle the modules using a build tool, to keep it even more tiny.

    opened by lukasoppermann 1
  • Fix offset() method

    Fix offset() method

    The offset was calculated relative to the viewport. pageYOffset / pageXOffset must be added to correct the result and return the offset relative to the whole document, like jQuery does.

    opened by kitten 0
  • Fix height method for document

    Fix height method for document

    When the height method was called on the document node ($(document).height()), the method just retuned undefined. This happened because it returned when the domType > 1, which is the case for document, which has a domType of 9.

    • Added an exception for nodeType == 9 in if clause
    • Added compatibility properties for document height / width
    • Removed window height as source
    opened by kitten 0
  • JS Perf Links Aren't Runnable

    JS Perf Links Aren't Runnable

    This looks like a sweet library with great potential and I'm excited to follow its development. Thought it was worth mentioning, though, that when I try to run any JSPerf tests linked to from the docs (example) JSPerf errors out with:

    ReferenceError: Sprint is not defined.
    
    ReferenceError: Zepto is not defined.
    

    So only JQuery works. I assume it is something wrong with the setup import code:

    <script src="https://sprintjs.com/prod"></script>
    <script src="https://zeptojs.com/zepto.min.js"></script>
    

    Keep up the good work!

    opened by andrewctate 0
  • Add git tags

    Add git tags

    Hi @bendc , Could you please add git tags so that the git auto-updater in cdnjs project can recognize the correct version? Thank you.

    https://github.com/cdnjs/cdnjs/issues/7776

    opened by pvnr0082t 0
Owner
Benjamin De Cock
I design and develop user interfaces.
Benjamin De Cock
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Javascript client for Sanity. Works in node.js and modern browsers (older browsers needs a Promise polyfill).

@sanity/client Javascript client for Sanity. Works in node.js and modern browsers (older browsers needs a Promise polyfill). Requirements Sanity Clien

Sanity 23 Nov 29, 2022
This package generates a unique ID/String for different browsers. Like chrome, Firefox and any other browsers which supports canvas and audio Fingerprinting.

Broprint.js The world's easiest, smallest and powerful visitor identifier for browsers. This package generates a unique ID/String for different browse

Rajesh Royal 68 Dec 25, 2022
🦆 lightning fast duckdb bindings for bun runtime

@evan/duckdb lightning fast duckdb bindings for bun runtime Install bun add @evan/duckdb Features ?? batteries included ?? jit optimized bindings ?? 4

evan 29 Oct 20, 2022
Zepto.js is a minimalist JavaScript library for modern browsers, with a jQuery-compatible API

Zepto.js – a minimalist JavaScript library Zepto is a minimalist JavaScript library for modern browsers with a largely jQuery-compatible API. If you u

Thomas Fuchs 15k Dec 31, 2022
A fast, vanilla JS customisable select box/text input plugin for modern browsers ⚡

choices A fast, vanilla, lightweight (~16kb gzipped ?? ), configurable select plugin for modern browsers. Similar to Select2 and Selectize but without

null 9 Aug 9, 2022
Reorderable drag-and-drop lists for modern browsers and touch devices. No jQuery or framework required.

Sortable Sortable is a JavaScript library for reorderable drag-and-drop lists. Demo: http://sortablejs.github.io/Sortable/ Features Supports touch dev

SortableJS 26.1k Jan 5, 2023
A tiny, plugin extendable JavaScript utility library with a JQuery-like syntax.

Tiny Friggin' Utility Zapper What is it? A tiny ~7kb extendable JavaScript utility library with a JQuery like syntax for getting work done fast! If yo

Bret 4 Jun 25, 2022
jQuery easy ticker is a news ticker like plugin, which scrolls the list infinitely. It is highly customizable, flexible with lot of features and works in all browsers.

jQuery Easy Ticker plugin jQuery easy ticker is a news ticker like plugin which scrolls a list infinitely. It is highly customizable, flexible with lo

Aakash Chakravarthy 208 Dec 20, 2022
Simple yet flexible charting Lightning Web Component using Chart.js for admins & developers

Lightning Web Chart.js Component Simple yet flexible charting Lightning Web Component using Chart.js for admins & developers Documentation Getting sta

@SalesforceLabs 109 Dec 9, 2022
A website for tracking community support for BIP21 QR codes that support on-chain and lightning bitcoin payments.

BIP21 Microsite This is a WIP microsite to promote the usage of a BIP21 payment URI QR code that can include lightning invoices or offers. Wallet supp

Stephen DeLorme 16 Nov 27, 2022
Inter Process Communication Module for node supporting Unix sockets, TCP, TLS, and UDP. Giving lightning speed on Linux, Mac, and Windows. Neural Networking in Node.JS

Inter Process Communication Module for node supporting Unix sockets, TCP, TLS, and UDP. Giving lightning speed on Linux, Mac, and Windows. Neural Networking in Node.JS

Node IPC 43 Dec 9, 2022
Web app that generates BOLT11 invoices from an LNURL or Lightning Address.

LNURL Pay ⚡️ Web app that generates BOLT11 invoices from an LNURL or Lightning Address. Getting Started First, run the development server: npm run dev

Sam Samskies 7 Nov 3, 2022
ln-charts parses the output of bos accounting commands into various charts for your Lightning Node.

ln-charts ln-charts parses the output of bos accounting commands into various charts for your Lightning Node. It runs on Angular, JS, HTML, CSS, ngx-c

Steven Ellis 21 Dec 18, 2022
A boilerplate project to build proof of concept paywalls with lightning service authentication tokens (LSATs)

lsat-workshop-boilerplate A boilerplate project to build proof of concept paywalls with lightning service authentication tokens (LSATs) Install Setup

Buck Perley 2 Oct 13, 2022
⚡️ Lightning Time: a new way to measure time

Lightning Time ⚡️ Lightning Time ⚡️ is a new way to measure time. It's a spin on hexadecimal time: the day is split into 16 parts over and over. The f

Purdue Hackers 7 Nov 22, 2022
A tiny blockchain node for browsers.

UBI Chain A very tiny blockchain for browsers. Features Spin up a node from a browser. One node per human via Proof of Humanity UBI for gas and fees.

Democracy Earth Foundation 15 Sep 29, 2022
A work-in-progress HTML sanitizer that strives for: performance like window.Sanitizer, readiness like DOMPurify, and ability to run in a WebWorker like neither of those.

Amuchina A work-in-progress HTML sanitizer that strives for: performance like window.Sanitizer, readiness like DOMPurify, and ability to run in a WebW

Fabio Spampinato 9 Sep 17, 2022