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

barba-custom.js

v1.0.12

Published

Barba.js it's a small, flexible and dependency free library that helps you creating fluid and smooth transition between your website's pages.

Downloads

5

Readme

This version is deprecated, look at v2.


barba.js is a small (4kb minified and gzipped), flexible and dependency free library that helps you creating fluid and smooth transitions between your website's pages.

It helps reducing the delay between your pages, minimizing browser HTTP requests and enhancing your user's web experience.


Websites using Barba.js

View demos

How it works

Barba.js uses PJAX (aka push state ajax) to enhance the user's experience.

This technique consist in preventing the normal link behavior, changing manually the browser url, and injecting manually the new content in the page. In this way there will be no browser "hard refresh".

Here is a walkthrough of what happens when the user clicks a link:

  1. Check if the link is valid and eligible for PJAX, if yes, prevent the normal browser behavior.
  2. Change the URL using Push State API.
  3. Start fetching the new page via XMLHttpRequest.
  4. Create a new transition instance.
  5. As soon the new page is loaded, barba.js parses the new HTML (taking .barba-container) and puts the new content on the DOM inside #barba-wrapper.
  6. The transition instance will take care to hide the old container and show the new one.
  7. As soon the transition is finished, the old container is removed from the DOM.

Please note, on server side, your pages will need to be served normally. Barba.js works as enhancement for your website, everything should work normally without Javascript.

In order to have a better understanding on how Barba.js works I suggest you to read this article I wrote for Smashing Magazine.

Why?

Using this technique will bring numerous benefits:

  • Possibility to create nice transition between pages enhancing the user's experience.
  • Reduce HTTP requests. (why reload the css/js at each page change?)
  • Possibility to speed up the navigation using prefetch and cache.

Features

Installation

barba.js supports AMD, CommonJS and Browser global (using UMD). You can install it using npm:

npm install barba.js --save-dev

or just including the script in your page:

<script src="barba.min.js" type="text/javascript"></script>

or you can use cdnjs:

<script src="https://cdnjs.cloudflare.com/ajax/libs/barba.js/1.0.0/barba.min.js" type="text/javascript"></script>

barba.js needs to know a little bit about your DOM structure. By default uses this markup structure in your pages:

<div id="barba-wrapper">
  <div class="barba-container">
    ...Put here the content you wish to change between pages...
  </div>
</div>

Please note, all the selector (#barba-wrapper, .barba-container) are easily editable, see the API section.

After you've included barba.js in your project it's time to initialize it

// Please note, the DOM should be ready
Barba.Pjax.start();

Contribute

Barba.js is created in the spare time by Luigi De Rosa and released under MIT licence. Any help on the project is more than welcomed. For any problem/question do not hesitate to open an issue.

Other

For any other information, please visit the website