The Pleasure (and Pain) of Script Upgrades

Our mission is to build quality, efficient and cutting edge software solutions for our clients while building strong, well-rounded careers for our employees.

25 January 2017 alan.monson@stgconsulting.com Comments Off on The Pleasure (and Pain) of Script Upgrades Scripted Technologies

Author: Geoffrey Sagers

If you are anything like me, you want the latest and greatest. In the area of web development, that can definitely be a double-edged sword. Using only the latest technology you shut out many users who either must use older browser due to corporate restrictions, or choose not to upgrade.
One of the most commonly used languages used on the internet is Javascript, and probably the most used Javascript plugin is jQuery. What is jQuery?

jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript.

The most current version (as of today is 3.1.1), but the most commonly used version by a large margin is still version 1 with close to 90% of all sites using it. So why is this? Some is just a webmaster overlooking an upgrade, but a fair amount is also because it just works.
Let me give you an example. On a recent assignment, I was tasked with upgrading a client’s site to the latest version of WordPress. The most recent version of WordPress (4.7) uses jQuery 1.13 by default. Their installation was an older version of WordPress with an older version of jQuery. The WordPress update went off without a hitch, but one of their Javascript add-ons (not WordPress plugins) stopped working.
I was puzzled. In looking through the add-on script, but saw nothing out of the ordinary. It used jQuery 1.7, but the differences between minor versions (after 1.6) is fairly small, so I didn’t think that was it. After a little rummaging, I managed to change WordPress to use version 1.7 (which is not recommended) just to verify, and that didn’t fix the problem.
After changing it back to version 1.13 in WordPress, I tried updating the script to use version 1.13 — but this also failed to bring it back to life. I was getting stumped.
Some of what STG helps its clients accomplish is to streamline systems. This particular client had had many web developers over the years, and each one brought in more plugins and addons to fit the client’s current needs. In looking through their WordPress installation, they had 37 plugins installed. My next step was to update each of the plugins. These also went off without a hitch, except one, that needed a file-by-file replacement (not ideal, but still worked fine in the end).
Still the problem remained. It had been several hours, and I was starting to become frustrated. As I looked through the plugins, and there was one that — according to its description, kept jQuery at the latest version. This sounded promising, so I disabled it. Eureka! The problem was solved! Just to double check, I re-enabled it, and sure enough the problem re-appeared.  To make a final pass, I copied the output of the page to a new document, re-enabled it, then did it again. When comparing these two files, I found that despite version 1.7 being loaded in the header of the page as expected, this plugin was loading version 3.1 further down. Problem solved!
In conclusion, when updating your scripts you didn’t write, watch for irregularities that probably will pop up from time to time. Keep your own scripts as up-to-date as possible, maintaining a balance between cutting-edge and audience capability. When keeping your site updated, keep up a regimen validating the use of plugins and scripts, and when they are not useful anymore, disable, or better yet, remove them. This will save you, and others like you, countless hours in the future debugging code.

Geoffrey Sagers
Senior Web Developer
Software Technology Group

Tags: