Lots of jQuery conflicts on Magento 2Getting TypeError: $.widget is not a function Magento 2Uncaught TypeError: undefined is not a function when using a jQuery plugin in MagentoMagento admin form date widget week number differs from jquery UI week numberJS errors Magento 2Jquery conflict with elastislide.js and prototype.jsWhy is js breaking with requirejs in templates on Magento 2 and how to fix?Continuing jQuery conflictsjQuery UI breaks when clicking on draggable element: “Cannot read property 'defaultView' of undefined”Add 2 jquery libraries to magento 2How to use third party jquery libraries in magento along with requirejs?Magento 2 - problem with mCustomscrollbar.js

How to tell your grandparent to not come to fetch you with their car?

Does the Long March-11 increase its thrust after clearing the launch tower?

Were Alexander the Great and Hephaestion lovers?

Meaning of 'lose their grip on the groins of their followers'

Mathematically, why does mass matrix / load vector lumping work?

Why can't I use =default for default ctors with a member initializer list

Which languages would be most useful in Europe at the end of the 19th century?

Is it legal for a bar bouncer to confiscate a fake ID

What to do when surprise and a high initiative roll conflict with the narrative?

Cascading Switches. Will it affect performance?

Fixing obscure 8080 emulator bug?

Does Disney no longer produce hand-drawn cartoon films?

Medieval flying castle propulsion

Generate basis elements of the Steenrod algebra

What's up with this leaf?

Should I give professor gift at the beginning of my PhD?

How can this tool find out registered domains from an IP?

Jargon request: "Canonical Form" of a word

Playing a Character as Unobtrusive and Subservient, Yet Not Passive

How to hide an urban landmark?

Soft question: Examples where lack of mathematical rigour cause security breaches?

Has there been a multiethnic Star Trek character?

is it possible for a vehicle to be manufactured witout a catalitic converter

Is it possible to have a wealthy country without a middle class?



Lots of jQuery conflicts on Magento 2


Getting TypeError: $.widget is not a function Magento 2Uncaught TypeError: undefined is not a function when using a jQuery plugin in MagentoMagento admin form date widget week number differs from jquery UI week numberJS errors Magento 2Jquery conflict with elastislide.js and prototype.jsWhy is js breaking with requirejs in templates on Magento 2 and how to fix?Continuing jQuery conflictsjQuery UI breaks when clicking on draggable element: “Cannot read property 'defaultView' of undefined”Add 2 jquery libraries to magento 2How to use third party jquery libraries in magento along with requirejs?Magento 2 - problem with mCustomscrollbar.js






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I'm working on a new Magento 2 installation with the Porto theme and have noticed that when you first visit the site or have the browser cache disabled you get a lot of of jQuery conflict errors. Below are examples of these errors from both the theme and core Magento2.



examples:



(index):394 Uncaught TypeError: $(...).swMegamenu is not a function
dataPost.js:13 Uncaught TypeError: $.widget is not a function


When I look how these jQuery functions are being initiated, I see it's using requireJs correctly to load jQuery.



<script type="text/javascript">
require([
'jquery',
'Smartwave_Megamenu/js/sw_megamenu'
], function ($)
$(".sw-megamenu").swMegamenu();
);
</script>


AND



define([
"jquery",
"mage/template",
"jquery/ui"
], function($,mageTemplate){

$.widget('mage.dataPost', {......


I can fix it by adding var $ = jQuery.noConflict(); at the beginning of the function block (but this seems redundant as $ is already passed as a parameter to the function, it works though!)



Also, I can fix it by Merging all JS as suggested in answer to this question.



Merging the JS seems to be a good fix but I'd like to better understand why this is happening and the best approach to solving it.










share|improve this question




























    0















    I'm working on a new Magento 2 installation with the Porto theme and have noticed that when you first visit the site or have the browser cache disabled you get a lot of of jQuery conflict errors. Below are examples of these errors from both the theme and core Magento2.



    examples:



    (index):394 Uncaught TypeError: $(...).swMegamenu is not a function
    dataPost.js:13 Uncaught TypeError: $.widget is not a function


    When I look how these jQuery functions are being initiated, I see it's using requireJs correctly to load jQuery.



    <script type="text/javascript">
    require([
    'jquery',
    'Smartwave_Megamenu/js/sw_megamenu'
    ], function ($)
    $(".sw-megamenu").swMegamenu();
    );
    </script>


    AND



    define([
    "jquery",
    "mage/template",
    "jquery/ui"
    ], function($,mageTemplate){

    $.widget('mage.dataPost', {......


    I can fix it by adding var $ = jQuery.noConflict(); at the beginning of the function block (but this seems redundant as $ is already passed as a parameter to the function, it works though!)



    Also, I can fix it by Merging all JS as suggested in answer to this question.



    Merging the JS seems to be a good fix but I'd like to better understand why this is happening and the best approach to solving it.










    share|improve this question
























      0












      0








      0








      I'm working on a new Magento 2 installation with the Porto theme and have noticed that when you first visit the site or have the browser cache disabled you get a lot of of jQuery conflict errors. Below are examples of these errors from both the theme and core Magento2.



      examples:



      (index):394 Uncaught TypeError: $(...).swMegamenu is not a function
      dataPost.js:13 Uncaught TypeError: $.widget is not a function


      When I look how these jQuery functions are being initiated, I see it's using requireJs correctly to load jQuery.



      <script type="text/javascript">
      require([
      'jquery',
      'Smartwave_Megamenu/js/sw_megamenu'
      ], function ($)
      $(".sw-megamenu").swMegamenu();
      );
      </script>


      AND



      define([
      "jquery",
      "mage/template",
      "jquery/ui"
      ], function($,mageTemplate){

      $.widget('mage.dataPost', {......


      I can fix it by adding var $ = jQuery.noConflict(); at the beginning of the function block (but this seems redundant as $ is already passed as a parameter to the function, it works though!)



      Also, I can fix it by Merging all JS as suggested in answer to this question.



      Merging the JS seems to be a good fix but I'd like to better understand why this is happening and the best approach to solving it.










      share|improve this question














      I'm working on a new Magento 2 installation with the Porto theme and have noticed that when you first visit the site or have the browser cache disabled you get a lot of of jQuery conflict errors. Below are examples of these errors from both the theme and core Magento2.



      examples:



      (index):394 Uncaught TypeError: $(...).swMegamenu is not a function
      dataPost.js:13 Uncaught TypeError: $.widget is not a function


      When I look how these jQuery functions are being initiated, I see it's using requireJs correctly to load jQuery.



      <script type="text/javascript">
      require([
      'jquery',
      'Smartwave_Megamenu/js/sw_megamenu'
      ], function ($)
      $(".sw-megamenu").swMegamenu();
      );
      </script>


      AND



      define([
      "jquery",
      "mage/template",
      "jquery/ui"
      ], function($,mageTemplate){

      $.widget('mage.dataPost', {......


      I can fix it by adding var $ = jQuery.noConflict(); at the beginning of the function block (but this seems redundant as $ is already passed as a parameter to the function, it works though!)



      Also, I can fix it by Merging all JS as suggested in answer to this question.



      Merging the JS seems to be a good fix but I'd like to better understand why this is happening and the best approach to solving it.







      magento2 javascript frontend jquery conflict






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Oct 2 '17 at 10:44









      HollyHolly

      2,36433882




      2,36433882




















          1 Answer
          1






          active

          oldest

          votes


















          0














          I had this issue as well but then I ran across this article: http://www.danjoseph.me/2016/09/16/magento-2-widget-not-function/



          In the article he explains that jquery was being loaded a second time on the page and therefore overwriting the version loaded previously by magento. For me it was a marketing script that was also loading jquery for some reason. jQuery should only be loaded once in the head by this tag and all others should be removed.



          <script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="jquery" src="http://seatup.local/pub/static/frontend/Seatup/theme/en_US/jquery.js"></script>






          share|improve this answer























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "479"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f195514%2flots-of-jquery-conflicts-on-magento-2%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I had this issue as well but then I ran across this article: http://www.danjoseph.me/2016/09/16/magento-2-widget-not-function/



            In the article he explains that jquery was being loaded a second time on the page and therefore overwriting the version loaded previously by magento. For me it was a marketing script that was also loading jquery for some reason. jQuery should only be loaded once in the head by this tag and all others should be removed.



            <script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="jquery" src="http://seatup.local/pub/static/frontend/Seatup/theme/en_US/jquery.js"></script>






            share|improve this answer



























              0














              I had this issue as well but then I ran across this article: http://www.danjoseph.me/2016/09/16/magento-2-widget-not-function/



              In the article he explains that jquery was being loaded a second time on the page and therefore overwriting the version loaded previously by magento. For me it was a marketing script that was also loading jquery for some reason. jQuery should only be loaded once in the head by this tag and all others should be removed.



              <script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="jquery" src="http://seatup.local/pub/static/frontend/Seatup/theme/en_US/jquery.js"></script>






              share|improve this answer

























                0












                0








                0







                I had this issue as well but then I ran across this article: http://www.danjoseph.me/2016/09/16/magento-2-widget-not-function/



                In the article he explains that jquery was being loaded a second time on the page and therefore overwriting the version loaded previously by magento. For me it was a marketing script that was also loading jquery for some reason. jQuery should only be loaded once in the head by this tag and all others should be removed.



                <script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="jquery" src="http://seatup.local/pub/static/frontend/Seatup/theme/en_US/jquery.js"></script>






                share|improve this answer













                I had this issue as well but then I ran across this article: http://www.danjoseph.me/2016/09/16/magento-2-widget-not-function/



                In the article he explains that jquery was being loaded a second time on the page and therefore overwriting the version loaded previously by magento. For me it was a marketing script that was also loading jquery for some reason. jQuery should only be loaded once in the head by this tag and all others should be removed.



                <script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="jquery" src="http://seatup.local/pub/static/frontend/Seatup/theme/en_US/jquery.js"></script>







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 6 '17 at 14:40









                Cypher909Cypher909

                20715




                20715



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Magento Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f195514%2flots-of-jquery-conflicts-on-magento-2%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

                    Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                    Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form