Pages

Tuesday, July 3, 2012

Jquery conflicts with Prototype

Use $$=jQuery.noConflict();

that's all

and then for all JQuery $ use $$

example

for $("#sdf")  use $$("#sdf")

4 comments:

  1. Having resources load from more than one domain reduces latency because you're having stress load put on more servers instead of all on one meaning you can have objects load simultaneously at blazing fast speeds.

    jquery jobs

    ReplyDelete
  2. From what you have said Alfred I infer that we should use more than one js frameworks in our regular web development projects.

    Because what I have heard is that we should use only one js framework if possible as using more than one requires loading of additional resources thus adding to latency..

    ReplyDelete
  3. Magento update on this
    Magento follows following JQuery process in order to a void conflicts with Prototype

    jQuery.noConflict();
    (
    function($)
    {
    $('a-selector').hide();
    $(
    function()
    {
    $('another-selector').show();
    }
    );
    }
    )(jQuery);

    ReplyDelete
  4. Also along with the way out mentioned in above post we can use

    jQuery.noConflict();
    jQuery('#select-me').show();

    Each one of above can be used but has certain drawbacks

    For the one mentioned in comment, there will be too many ‘jQuery’ in your codes instead of ‘$’, which don’t have to be. And the existed library would be replaced if an additional jQuery library is loaded.

    For the one in post, loading jQuery library many times makes your site slower and less professional. Also, an additional namespace ‘$$’ is created, which may activate some programmers’ passion for cleanliness!

    ReplyDelete