WP Engine

Solutions
AgencyEnterpriseSmall & Medium BusinessMarketer
How WP Engine supports marketers.Benefits for marketers.Features that help you innovate.
Developer
How WP Engine supports developers.Benefits for developers.Features that help you move faster.
Explore Our Platform
Insights
Thought LeadershipTopics

Read articles, trends, and insights on these topics from leaders in marketing and technology.

Creative AgilityEnterprise PerformanceActionable IntelligenceEcosystem Integration
Resources

Access ebooks, whitepapers, webinars, and other knowledge from our ecosystem of digital experts.
Visit Resource Center.

Delivering a Slam Dunk Experience on WordPressEbook: The Ultimate Guide to WordPress Plugins15 Common WordPress Mistakes Agencies and their Clients Make
Case Studies
About
Our CompanyOur PlatformLatest News

Access the latest news from inside WP Engine.
Visit the Newsroom.

WP Engine Secures Strategic Growth Investment From Silver LakeWP Engine Unveils First WordPress Digital ExperienceWP Engine Expands Global Presence with New Office in Brisbane
Media Center

Get announcements and resources about WP Engine.

Press Releases
Careers at WP Engine
Pricing
Sales Questions?

Contact Sales

Discover why organizations of all types and sizes choose WP Engine — and how it can benefit you.

Chat

1

I'm available right now to answer any of your questions!

Reply

Call

+1-512-201-4819

Contact

Send a message

Compare Plans
Need Support?
Support DocumentationBilling HelpSupport

We offer support 24 hours a day, 7 days a week, 365 days a year. Log in to get expert one-on-one help.

Log in for support

Sales Questions

Contact Sales

Discover why organizations of all types and sizes choose WP Engine — and how it can benefit you.

Chat

1

I'm available right now to answer any of your questions!

Reply

Call

+1-512-201-4819

Contact

Send a message

Sign in
Sign in
Search

Search

Compare Plans
Call Sales +1-512-201-4819
Menu
AgencyEnterpriseSmall & Medium BusinessMarketers
How WP Engine supports marketers.Benefits for marketersFeatures that help you innovate.
Developers
How WP Engine supports developers.Benefits for developers.Features that help you move faster.
Our PlatformPricingResource CenterOur CompanySolution CenterThought LeadershipDocumentationCareers

Quick and dirty developer fix: Going Line-By-Line

Austin Gunter 2.29.2012

The ideal way to solve the problem of jQuery libraries thrown off is simple, but it’s also a pain in the ass.  In the previous post, we saw how conflicting jQuery libraries can cause problems.  That example was a site that was running a plugin with a previous version of jQuery hardcoded in, which was creating HTML errors that didn’t point directly to the jQuery issues.

To solve a challenging issue like this, we don’t get fancy, we just roll up our sleeves and show our true colors: we’re nerds, and we know way too much about WordPress for our own good.

Take all the code and copy it into an HTML file, start going through the code, cutting pieces of suspect code and publishing.  More than likely, there will be plenty of code that you can cut out before you cut out the culprit and see the error go away.  Put the code back in in order to verify that you’ve found the right snippet.  Once you’ve isolated the right code, you’re ready to roll.

Excerpted from the actual Support Ticket between Jason Cohen and our customer.

I found it! It’s the JQuery library.

If you use this, it works: http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js 
If you use this, it doesn’t work: http://[awesomewebsite].wpengine.netdna-cdn.com/wp-includes/js/jquery/jquery.js?ver=1.6.1

The reason is that in Google’s version it defines ‘$’ as a function, and in the other it does NOT define that.

So… ANOTHER way to fix it is to use “jQuery” instead of ‘$’ in that function that’s failing. That’s the fastest.

Phew!

What I did was copy your html into a static html file on my laptop so  I could reproduce the problem.  Then I stripped out javascript piece by piece until I was left with just a little, and still reproduced the problem.

At that point I could replace the ‘$’ with jQuery and it fixed the problem. And same with switching out the jQuery bit.

I’ve attached that file.

Okay Jason, this is totally resolved. Thanks for all of your help on this.

It was something else on the page. Another jquery library is being called in the footer. If that was removed, everything worked just fine. However, on removal it broke other items on the site. I’ll debug this later, but my  fix for now was to move all the scripts to the footer.

There ya go, guys.  Let us know if you ever run into a similar issue.  We’re here to help!

Also, we’re going to continue posting content like this Monday and Wednesday every week.  You can get these posts in your email with the Feedburner link up top so you don’t have to remember to check back twice a week.  ALSO, let us know if you have a tip you want us to post.

More WordPress news from WP Engine

Advanced Feature- HTML Regex ReplacementsFinely Tuned Consultant: David Vogelpohl

Comments

  1. Greg Johnson says

    March 2, 2012 at 12:27 pm

    This is a pretty cool post, in that you’re showing perhaps more inexperienced developers how to troubleshoot annoying JS-based problems.

    I have to take issue, though, with the suggestion that the problem was the use of the wrong jQuery library. I’ve run into this problem quite a few times myself, where, when porting jQuery code into a WP-Powered site, it breaks, with no easily discernible reason as to why… at first.

    At first, I just switched to the google cdn version as well, but because of my lack of knowledge, the google cdn version was being loaded both on the front-end and the back end. This broke the drag-and-drop system in WP-Admin and cause problems with page/post management as well.

    The recommended solution, as seen here: http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_wrappers

    Is to ensure that any plugins, theme javascripts, etc are complying with the jQuery.noConflict wrapper… that’s why using jQuery( … ) was working where as $( … ) was not… if you inspected the element using firebug or chrome element inspector you would see clearly in the error log that ‘$’ is undefined. Easy fix?

    use a jQuery noConflict wrapper in your code to redefine the ‘$’ used in client-code… e.g.: `jQuery( document).ready(function( $ ) {});` ( note the ‘$’ in the anonymous function being passed to ready() )

    If THAT still doesn’t work, the theme functions.php file should be edited to de-register the core WP provided jQuery and register the google CDN version. wp_deregister_script and wp_register_script/wp_enqueue_script respectively.

    Thanks for the great article, and for letting me add my two cents!

    – Greg J

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Subscribe

    Subscribe to our blog to get great tips for your WordPress site.

  • Favorite Tweets by @wpengine
  • Sign In

    Solutions

    • Agency
    • Enterprise
    • SMB
    • Marketer
    • Developer

    Insights

    • Blog
    • Torque
    • Velocitize

    About

    • Our Company
    • Leadership Team
    • Our Platform
    • Careers
    • Affiliates
    • Contact
    • Legal
    • Newsroom
    • Privacy Policy

    Resources

    • Resource Center
    • Documentation
    • Solution Center
    • Find an Agency

    WP Engine

    504 Lavaca Street, Suite 1000
    Austin, TX 78701

    Sales

    +1-512-201-4819
    [email protected]
    7am–7pm CST

    Billing

    [email protected]

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Instagram
    • RSS
    © 2013—2026 WPEngine, Inc. All rights reserved.
    WP ENGINE®, VELOCITIZE®, TORQUE®, EVERCACHE®, and the cog logo service marks are owned by WPEngine, Inc.