Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    7
    Thanks
    3
    Thanked 0 Times in 0 Posts

    JavaScript Conflicts

    I have been given the task of merging all of the javascript of 3 different websites into one file.

    I think that some of the JS is conflicting, but I don't know.
    I am not that experienced with JavaScript.

    Some of the JS is using jQuery.

    I have multiple anonymous jQuery functions:
    Code:
    (function ($) { 
        // Javascript code 
    })(jQuery)
    Notepad++ tells me there are 7 instances of:
    Code:
    (function (a)
    I am guessing there is no doubt that would cause conflict?

    What are some common things that cause conflicts in JavaScript?

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,910
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Quote Originally Posted by _chris View Post
    I am guessing there is no doubt that would cause conflict?

    What are some common things that cause conflicts in JavaScript?
    Duplicate function and/or variable names, and multiple onload statements.
    Also using two different Javascript frameworks (say jQuery and Mootools)

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •