npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jquasi

v2.0.0

Published

A very tiny jquery-syntax-like library for DOM manipulation and listeners. IE9+ compatible

Downloads

47

Readme

Build Status Coverage Status

What

This is a tiny (4kB minified) and IE9+ compatible library to interact with the DOM using a jQuery-like syntax.

Why

I love jQuery. But sometimes I only need to do a few things using a chainable|comfortable syntax. Frameworks like Angular, React or Vuejs may be oversized for a simple page with little interactivity.

In this case jquasi might help. With this 4kB library you can do something like this:


$(function() {
    $('body').append(
        $('<a/>')
            .attr("href","#")
            .html("Simple link")
            .on('click', function(e) {
                $(this)
                    .toggleClass('a-clicked')
                    .html("clicked!");
                return false;
            })
    );
});

Of course jquasi is not a complete replacement of jQuery, but a subset with a compatible syntax/API. So you can start your project with jquasi and later - if you miss some features - switch to jQuery without changing anything in your code!

Repository structure

  • The spec folder contains tests that work with both jQuery and jquasi.
  • The dist folder contains the minified version (3k) of jquasi.

API / supported features

The API is a subset of the jQuery API.

  • ready: $(function() {/* document is ready now */})
  • create: $('<div/>')
  • selectors: $('.classname[attr="value"]). This use the document.querySelectorAll
  • each: $('div').each(function() {console.log(this)})
  • (add|remove|toggle|has)Class $('div').addClass("class-for-all-div")
  • attr: $('div').attr("data-attr", "value")
  • .html()
  • append: $('body').append($('<div/>'))
  • parent: $('.my-div').parent().parent()
  • remove, clone, empty
  • get: get()
  • find: find()
  • listeners $('body').on('click',function() {})
  • event delegation: $('body').on('click','.only-this',function() {})
  • remove listeners $('body').off('click')
  • namespaced events $('body').on('click.my-custom-namespace')
  • remove namespaced events $('body').off('.my-custom-namespace')
  • remove all delegated event handlers $('body').off('click', '**')
  • .fn as prototype shortcut

From 2.0

  • .html(content) supports now script tag execution.
  • .attr(name) returns undefined rather than null respecting jQuery compatibility
  • .css() for simple a minimal styling
  • removeAttr: $('div').removeAttr("data-attr")

This API is a good balance of lightness and power.

Extending jquasi / adding missing functionalities

If you are missing just a few methods and don't want to switch from jquasi to jQuery, you can extend jquasi within your project as shown in this example:

$.fn.myMissingFunc = function() {
    // do stuff here
}

$('div').css("backgroundColor","red");

Contributing

Fixes and contributions are welcome.

If you wrote an extension in your project and believe it could be of general interest, feel free to open a Pull Request to discuss its inclusion in the main project.

Consider that this library must remain jquery compatible and as small as possible.

To set up the development environment, clone this repo and run:

npm install

to download all dependencies needed for compilation and testing inside the src folder.

To test your changes run:

npm test

to run the tests using chrome headless OR open the spec/standalone/SpecRunner.html file with your favourite browser.

If you are adding new functionalities, please write the corresponding tests as well.

To create the minified version of jquasi run:

npm run build