When you’re building a distributable package for a framework that is likely to have several other third-party packages installed, it’s difficult to know when modifications or additions to the framework have already been made further up the chain of operations. I recently ran into this in a package I built that relies on jQuery – another package installed on the system had already included and extended the jQuery object. When my addition came into play, the jQuery object was reset and the other package broke as a result.

To fix this, I wrote a script to test if the jQuery object had been instantiated yet and, if not, to load it. Here’s what it looks like:

if (typeof jQuery === 'undefined') {
    document.write(unescape("%3Cscript src='http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js' type='text/javascript'%3E%3C/script%3E"));
}

Share this article:

If this resonates with you I'd love to help!

I help business with problems like these every day.

Click below to schedule a call.

About The Author

Bryce Hamrick

Facebook Twitter

Bryce Hamrick is an entrepreneur, business & marketing strategist, and product consultant with nearly two decades of experience in industry. Bryce has been a software engineer, product manager, and director of product management for startups as well as large enterprises. He has led teams to bring dozens of products to market and has executed numerous six-figure product launches. Today Bryce and his team focus on leveraging his product execution strategy to help businesses with growth and scale.