jQuery for the script guy

by Andy for Blog
jQuery for the script guy

jQuery is the most used Javascript library in the world. It’s also one of the most hated. jQuery like all libraries has it’s advantages: it’s simple to use, is cross browser compatible and makes web pages interactive with only a few lines of code. Sounds great right? Only problem is that it impacts website performance!

To begin, in order to use jQuery you need to add an external javascript file like ‘jquery.min.js’ which is a 30kb file. This file load time can add 7 milliseconds of delay to your page load, this might not sound like a lot but imagine a user with slow internet or mobile connection.

If you’ve added the library using google’s jQuery url ‘https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js’ then this would normally already be cached in the browser because a lot of website use jquery. Still though a delay is a delay.

Excluding the delay from the external file, jQuery is a lot slower than pure javascript or ‘vanilla’ javascript as it’s known in the industry. Even a simple task like adding a node to the DOM (Document Object Model) instead of a simple api call, jQuery performs multiple unnecessary operations for changing the DOM.

So what alternatives are there, other than re-writing your jquery functions in pure javascript, which is supported by all modern browsers, an alternative is to use a lightweight alternative such as Cash.

Pure Javascript examples for common jquery functions.

JavaScript Get Request


JavaScript POST


JavaScript Hide & Show


JavaScript Find


JavaScript Append


JavaScript Remove


JavaScript Get Html


JavaScript Get Text


JavaScript Set Style


JavaScript Set Html


JavaScript Add Class


JavaScript Remove Class


7 ways to use your Raspberry Pi
Prev post Unit Testing

A unit test is an automated test that makes calls to your code to check…

7 ways to use your Raspberry Pi
Next post 7 ways to use your Raspberry Pi

Raspberry Pi is a "charity that works to put the power of computing and digital…