DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Coding
  3. Frameworks
  4. A Tiny Yet Powerful Alternative to jQuery

A Tiny Yet Powerful Alternative to jQuery

In this post we'll introduce the tiny, fast Umbrella JS library, and how to use it instead of jQuery for creating fast client-side JavaScript.

Jean-Baptiste Jung user avatar by
Jean-Baptiste Jung
·
Mar. 29, 17 · Opinion
Like (4)
Save
Tweet
Share
7.13K Views

Join the DZone community and get the full member experience.

Join For Free

jQuery has been by far the most popular JavaScript library for the last 5 years. It's powerful, easy to use, and widespread. However, the latest jQuery release is 250kb. Since website speed is extremely important, what about giving Umbrella JS, which is only 4kb, a try? Let's have a look at this new and promising JavaScript library.

Why Umbrella JS?

jQuery is an amazing piece of code! Since its first release in 2006, jQuery has played a key role in shaping the web as we know it nowadays. Still, every now and then a new JavaScript library is released. One that caught my attention lately is Umbrella JS, a library heavily influenced by jQuery, but way more compact (3kb!) and limited to DOM manipulation, events, and Ajax.

So what are the top advantages in using Umbrella JS?

  • It’s super lightweight: Umbrella JS is only 3kb minified, which ensures super fast loading speeds, even on mobile devices. Website loading speed is now an extremely important factor in search engine rankings and ease of use for mobile users, so this is indeed a great thing.
  • It’s easy to use: Umbrella JS is heavily influenced by jQuery. If you know jQuery’s syntax, adapting to Umbrella JS will be very easy.
  • It’s complete: Despite being small in size, Umbrella JS contains everything you need for DOM manipulation, events, and Ajax.
  • It’s free: Released under the terms of the MIT license, Umbrella JS can be used freely in all your projects.

Installation and Usage

Installing Umbrella JS is easy. You can use JSdelivr CDN, or download the .js file and add it to your HTML document:

<script src="umbrella.min.js"></script>

If you want to test and experiment with Umbrella JS, you can do so in JS Fiddle.

A Few Snippets

Now let’s see what we can do with Umbrella JS. If you’re familiar with jQuery, you will get the syntax very easily. If you want more snippets and examples, check out the documentation.

Simple event

Handling a simple event: When the user clicks on a button, an alert is displayed.

u("button").on('click', function(){
  alert("Hello world");
});

Automatic target=”_blank” on Links

A good example of the each() function, which is used to loop through all of the nodes and to execute a callback for each.

u('a').each(function(node, i){
  u(node).attr({ target: '_blank' });
});

Ajax

Performing Ajax requests is even easier than with jQuery.

u('form').ajax(function(err, data){
  if (!err) alert('Done! Thanks, ' + data.name);
});

Scroll to an Element

As seen on many websites, clicking on a link with the class team will scroll to the first <section> element with the class team:

u('a.team').on('click', function(e){
  e.preventDefault();
  u('section.team').scroll();
});

Auto-Save a Form Every 10 Seconds

Using the ajax() and trigger() functions, it only takes a few lines to create an auto-save function for any kind of form.

// Make the form to submit through ajax
u('form.edit').ajax();

// Submit it every 10s
setInterval(function(){
  u('form.edit').trigger('submit');
}, 10000);

Do you have any Umbrella JS experiences to share? Leave a comment below.

JQuery

Published at DZone with permission of Jean-Baptiste Jung, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Multi-Tenant Architecture for a SaaS Application on AWS
  • DeveloperWeek 2023: The Enterprise Community Sharing Security Best Practices
  • How To Set Up and Run Cypress Test Cases in CI/CD TeamCity
  • A Gentle Introduction to Kubernetes

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: