{"id":19787,"date":"2019-03-07T14:50:15","date_gmt":"2019-03-07T12:50:15","guid":{"rendered":"https:\/\/belvg.com\/blog\/?p=19787"},"modified":"2026-07-08T10:54:00","modified_gmt":"2026-07-08T08:54:00","slug":"how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions","status":"publish","type":"post","link":"https:\/\/belvg.com\/blog\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html","title":{"rendered":"How to use jQuery and requireJS in Magento 2? 2026 JavaScript Solutions"},"content":{"rendered":"<p>To give your online store a modern, smart look without globally altering the current design, you can include dynamic, changing elements in it. The best solution for adding such elements in Magento 2 is JavaScript, and how to work with it we already described in the previous article.<\/p>\n<p><!--more--><\/p>\n<p>Although Magento continues to support jQuery and RequireJS in its frontend architecture, many custom projects also use modern JavaScript tooling for standalone applications and integrations. Understanding the native Magento JavaScript stack remains important when developing or maintaining themes and modules in 2026.<\/p>\n<p>In today&#8217;s blog post, we will go over the jQuery, jQuery UI widgets, and RequireJS &#8211; the important tools the developer needs to master if they want to work productively with JavaScript in Magento 2.<\/p>\n<p><strong>Table of Contents:<\/strong><\/p>\n<p><a href=\"#step_1\">What are jQuery and jQuery UI widgets?<br \/>\n<\/a><a href=\"#step_2\">How can jQuery UI Widget methods be instantiated?<br \/>\n<\/a><a href=\"#step_3\">How can you add new methods to a jQuery UI Widget?<br \/>\n<\/a><a href=\"#step_4\">How can a jQuery UI Widget method be wrapped with custom logic?<br \/>\n<\/a><a href=\"#step_5\">How do you load a file with require.js and define a require.js module?<br \/>\n<\/a><a href=\"#step_6\">How are require.js module dependencies specified?<br \/>\n<\/a><a href=\"#step_7\">How are module aliases configured in requirejs-config.js?<br \/>\n<\/a><a href=\"#step_8\">How do you debug which file a requireJS alias refers to?<\/a><\/p>\n<h2 id=\"step_1\">What are jQuery and jQuery UI widgets?<\/h2>\n<p>To simplify the creation of various elements like drop-down lists, accordions, buttons, datepickers, etc., Magento implements jQuery and jQuery UI libraries.<\/p>\n<p>If you compare jQuery and pure JS, then the jQuery code is significantly shorter and simpler, but at the same time has a far larger load on browser performance.<\/p>\n<p>jQuery UI is a library extension that provides a set of out-of-the-box widgets for projects.<\/p>\n<p><strong>How to use Magento core jQuery widgets?<\/strong><\/p>\n<p>Magento uses jQuery UI widgets to save development time, so the most commonly used elements in projects are already available for use with no need for configuration.<\/p>\n<p>Practically, in any project, you have to make an FAQ page, or tabs with product descriptions, and a date picker or slider will be the widgets that you will most likely use in your theme for that purpose.<\/p>\n<h2 id=\"step_2\">How can jQuery UI Widget methods be instantiated?<\/h2>\n<p>Using the accordion as an example ($ (&#8220;# element&#8221;). accordion ();) I will show you how the call process is performed. It can be done in different ways.<\/p>\n<p>Method #1: In the template, using the script.<\/p>\n<pre class=\"lang:default decode:true \">&lt;script&gt;\r\n    require([\r\n        'jquery',\r\n        'accordion'], function ($) {\r\n        $(\"#element\").accordion();\r\n    });\r\n&lt;\/script&gt;<\/pre>\n<p>Method #2:&#160;In the template, using data-mage-init.<\/p>\n<pre class=\"lang:default decode:true\">&lt;div id=\"element\" data-mage-init='{\"collapsible\":{\"openedState\": \"active\", \"collapsible\": true, \"active\": true, \"collateral\": { \"openedState\": \"filter-active\", \"element\": \"body\" } }}'&gt;\r\n    &lt;div data-role=\"collapsible\"&gt;\r\n        &lt;div data-role=\"trigger\"&gt;\r\n            &lt;span&gt;Title 1&amp;lt;\/span&gt;\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n    &lt;div data-role=\"content\"&gt;Content 1&lt;\/div&gt;\r\n<\/pre>\n<p>Method #3:&#160;In the script file, using a selector, or by calling a function.<\/p>\n<pre class=\"lang:default decode:true \">require([\r\n        'jquery',\r\n        'accordion'], function ($) {\r\n        $(\"#element\").accordion();\r\n    });\r\n<\/pre>\n<p>Method #4:&#160;Using <em>&lt;script type=&#8221;text\/x-magento-init&#8221; \/&gt;.<\/em><\/p>\n<pre class=\"lang:default decode:true\">&lt;script type=\"text\/x-magento-init\"&gt;\r\n{\r\n\t\"#element\": { \/\/ your selector that uses the widget\r\n\t\t\"accordion\": \/\/ variables are listed here, for example &lt;?php echo $block-&gt;getNavigationAccordionConfig(); ?&gt;\r\n\r\n}\r\n}\r\n&lt;script&gt;\r\n<\/pre>\n<p id=\"step_4\"><strong>How can you call jQuery UI Widget methods?<\/strong><\/p>\n<p>It is executed with the following code:<\/p>\n<pre class=\"lang:default decode:true \">$ ('# element'). accordion (\"someAction\");\r\n<\/pre>\n<p>Call the widget and the function we want via the method.<\/p>\n<h2 id=\"step_3\">How can you add new methods to a jQuery UI Widget?<\/h2>\n<p>To add new methods to a jQuery UI Widget, we either add an existing widget (using mixin), or create a custom component ourselves. The first option is preferable when we aim to only expand the existing code. Otherwise, when you work from scratch, it is better to stick to the second one.<\/p>\n<p>Let&#8217;s consider the first path:<\/p>\n<p><em><span style=\"font-weight: 400;\">app\/code\/Vendor\/Module\/view\/frontend\/requirejs-config.js<\/span><\/em><\/p>\n<pre class=\"lang:default decode:true\">var config = {\r\n\"config\": {\r\n\"mixins\": {\r\n\"mage\/tabs\": {\r\n'Vendor_Module\/js\/accordion-mixin': true\r\n}\r\n}\r\n}\r\n};\r\n<\/pre>\n<p><em>app\/code\/Vendor\/Module\/view\/frontend\/web\/js\/accordion-mixin.js<\/em><\/p>\n<pre class=\"lang:default decode:true \">define([\r\n'jquery'\r\n], function($) {\r\nreturn function (original) {\r\n$.widget('mage.accordion', original, {\r\nactivate: function() {\r\n\/\/ your code here\r\nreturn this._super();\r\n}\r\n}\r\n);\r\nreturn $['mage']['accordion'];\r\n}\r\n});\r\n<\/pre>\n<h2 id=\"step_4\">How can a jQuery UI Widget method be wrapped with custom logic?<\/h2>\n<p>The second option is to introduce a custom component:<\/p>\n<p><em>app\/code\/Vendor\/Module\/view\/frontend\/web\/js\/custom-accordion.js<\/em><\/p>\n<pre class=\"lang:default decode:true\">define([\r\n'jquery',\r\n'jquery\/ui',\r\n'mage\/accordion'\r\n], function($) {\r\n$.widget('vendor.customAccordion', $.mage.accordion, {\r\nsomeAction: function(element) {\r\n\/\/ your code here\r\n}\r\n});\r\n});\r\n<\/pre>\n<p>Then we add to the template the following:<\/p>\n<p><em>app\/code\/Vendor\/Module\/view\/frontend\/templates\/test.phtml<\/em><\/p>\n<pre class=\"lang:default decode:true\">&lt;div id=\"element\"&gt;&lt;\/div&gt;\r\n&lt;script&gt;\r\nrequire([\r\n'jquery',\r\n'Vendor_Module\/js\/custom-accordion'], function ($) {\r\n$(\"#element\").customAccordion();\r\n$(\"#element\").customAccordion(\"someAction\");\r\n\/\/ Calling the vidget function the way we described before\r\n});\r\n&lt;\/script&gt;\r\n<\/pre>\n<h2><strong>How do you load a file with require.js and&#160;define a require.js module?<\/strong><\/h2>\n<p>Magento 2 introduced a number of innovations in the use of JavaScript, and one of them is requireJS (JavaScript file loader).<\/p>\n<p><span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\">In order to add the JS file to your Magento 2 custom module, you need to add the&#160;<strong>requirejs-config.js<\/strong>&#160;file to your module at the path&#160;<em>app \/ code \/ &lt;Company&gt; \/ &lt;modulename&gt; \/ view \/ frontend.<\/em><\/span><\/p>\n<pre class=\"lang:default decode:true \">var config = {\r\n    map: {\r\n        '*': {\r\n            belvgmodule: 'Company_modulename\/js\/belvgrequirejs',\r\n        }\r\n    }\r\n};\r\n<\/pre>\n<p>For example, in this case, the map property contains an object with the key that is an alias to a file and the value that is the real path to the file.<\/p>\n<p>&#8220;*&#8221; Is used to determine that you are using a new module in RequireJS; if you want to add a file to the existing module, you will need to specify the name of the module instead of &#8220;*&#8221;.<\/p>\n<p>No file extension is required, because the system accepts js as the default type.<\/p>\n<p>The united configuration will be loaded to the page immediately after require.js and will be used by the require () and define () functions.<\/p>\n<p>Let me show you how to define a RequireJS module using a <em>helper \/ belvg<\/em> module as an example. To use the module, we need to add the following code to the JS file (main.js for example):<\/p>\n<pre class=\"lang:default decode:true \">requirejs(['helper\/belvg'], function(helper_belvg) {\r\n    var message = helper_belvg.getMessage();\r\n    alert(message);\r\n});<\/pre>\n<p>We specify the modules as an array that we want to load and pass this array as the first argument to the require.js function call. RequireJS then passes the object that exports the <strong>helper \/ belvg<\/strong> module to our main function as the first parameter of<strong> helper_belvg<\/strong>.<\/p>\n<p>Then we need to define a <strong>helper \/ belvg<\/strong> module. To define a module, turn the module name into a file path, and add the following contents (scripts \/ helper \/ belvg.js):<\/p>\n<pre class=\"lang:default decode:true \">define([], function(){\r\n    var x = {};\r\n    x.getMessage = function()\r\n    {\r\n        return 'Some message';\r\n    }\r\n    return x;\r\n});<\/pre>\n<p>When adding custom JavaScript, it is also a good practice to avoid overriding Magento core files whenever possible. Using mixins, widgets, and RequireJS configuration helps keep customizations upgrade-friendly and makes future maintenance easier.<\/p>\n<h2 id=\"step_6\">How are require.js module dependencies specified?<\/h2>\n<p>To build a dependency on a third-party plugin, specify <strong>[shim]<\/strong> in the following configuration files:<\/p>\n<p>requirejs-config.js<\/p>\n<pre class=\"lang:default decode:true \">var config = {\r\n     \"shim\": {\r\n     \"3-rd-party-plugin\": [\"jquery\"]\r\n     }\r\n };<\/pre>\n<p>&lt;third-party-plugin&gt;.js<\/p>\n<pre class=\"lang:default decode:true \">!(function($){\r\n     \/\/ plugin code\r\n     \/\/ where $ == jQuery\r\n })(jQuery);<\/pre>\n<h2 id=\"step_7\">How are module aliases configured in requirejs-config.js?<\/h2>\n<p>In our example, the name of the module RequireJS was tied to the location of this module on the disk. In other words, the <strong>helper \/ belvg<\/strong> module will always be located in the<strong> helper \/ belvg.js<\/strong> path.<\/p>\n<p>RequireJS allows you to change this through configuration. For example, if you want your <strong>helper \/ belvg<\/strong> module to be called hello, you would run the following configuration code before running your program:<\/p>\n<pre class=\"lang:default decode:true \">require.config({   \r\n    paths: {        \r\n        \"hello\": \"helper\/belvg\"\r\n    },\r\n});<\/pre>\n<p>The paths configuration key is the place where we can rename the modules. The paths object key is the name you want to assign (hello), and the value is the actual module name (<strong>helper \/ belvg<\/strong>).<\/p>\n<p>Therefore, we can work with the module like this:<\/p>\n<pre class=\"lang:default decode:true \">requirejs(['hello'], function(hello) {\r\n    alert(\"Some message\");\r\n});<\/pre>\n<h3 id=\"step_11\">How do you regenerate the compiled requirejs-config.js file after changes?<\/h3>\n<p>Remove static content and execute:<\/p>\n<p><em>php bin \/<\/em> <em>magento<\/em> <em>cache: clean<\/em><\/p>\n<h2 id=\"step_8\">How do you debug which file a requireJS alias refers to?<\/h2>\n<p>To track which file corresponds to the renamed module, you need to open the<strong> requirejs-config.js<\/strong> file:<\/p>\n<pre class=\"lang:default decode:true \">var config = { \r\n    map: { \r\n        '*': { \r\n            addToCart: 'Magento_Module\/js\/module' \r\n         } \r\n     } \r\n};\r\n<\/pre>\n<p>You can find the key map in the file, which contains the aliases parameters of the module and its path.<\/p>\n<p>Demonstrate that you understand how to create and configure Magento JavaScript mixins.<br \/>\nMagento 2 comes with a variety of functional capabilities, and when it comes to redefining the JavaScript component or extending the JavaScript component in Magento 2, you need to use mixins.<\/p>\n<p>Mixins are JavaScript files located in the <strong>web \/ js<\/strong> directory. A mixin file can be embedded in several directories if these directories are in <strong>web \/ js<\/strong>.<\/p>\n<p>The example of creating a mixin for custom product samples:<\/p>\n<p>Step 1. Create <strong>app\/code\/VendorName\/ModuleName\/view\/frontend\/requirejs-config.js<\/strong><\/p>\n<pre class=\"lang:default decode:true \">var config = {\r\n    config: {\r\n        mixins: {\r\n            'Magento_Swatches\/js\/swatch-renderer': {\r\n                'VendorName_ModuleName\/js\/swatch-renderer-mixin': true\r\n            }\r\n        }\r\n    }\r\n};<\/pre>\n<p>Step 2. Create <strong>app\/code\/VendorName\/ModuleName\/view\/frontend\/web\/js\/swatch-renderer-mixin.js.<\/strong><\/p>\n<pre class=\"lang:default decode:true \">define(['jquery'], function ($) {\r\n    'use strict';\r\n\r\n    return function (SwatchRenderer) {\r\n        $.widget('VendorName.SwatchRenderer', $['mage']['SwatchRenderer'], {\r\n            _init: function () {\r\n                console.log('getProductSwatchRenderer');\r\n                this._super();\r\n            }\r\n        });\r\n        return $['mage']['SwatchRenderer'];\r\n    };\r\n});<\/pre>\n<p>The example of mixin for Magento_Checkout payment information:<br \/>\n1. Create app\/code\/VendorName\/ModuleName\/view\/frontend\/requirejs-config.js<\/p>\n<pre class=\"lang:default decode:true \">\/**\r\n * Copyright &#169; Magento, Inc. All rights reserved.\r\n * See COPYING.txt for license details.\r\n *\/\r\n\r\nvar config = {\r\n    config: {\r\n        mixins: {\r\n            'Magento_Checkout\/js\/action\/set-payment-information': {\r\n                'Magento_CheckoutAgreements\/js\/model\/set-payment-information-mixin': true\r\n            }\r\n        }\r\n    }\r\n};\r\n<\/pre>\n<p><span style=\"font-weight: 400;\">2. Create app\/code\/VendorName\/ModuleName\/view\/frontend\/web\/js\/set-payment-information-mixin.js&#160;<\/span><span style=\"font-weight: 400;\">(example: \/<\/span><span style=\"font-weight: 400;\">app<\/span><span style=\"font-weight: 400;\">\/<\/span><span style=\"font-weight: 400;\">code<\/span><span style=\"font-weight: 400;\">\/<\/span><span style=\"font-weight: 400;\">Magento<\/span><span style=\"font-weight: 400;\">\/<\/span><span style=\"font-weight: 400;\">CheckoutAgreements<\/span><span style=\"font-weight: 400;\">\/<\/span><span style=\"font-weight: 400;\">view<\/span><span style=\"font-weight: 400;\">\/<\/span><span style=\"font-weight: 400;\">frontend<\/span><span style=\"font-weight: 400;\">\/<\/span><span style=\"font-weight: 400;\">web<\/span><span style=\"font-weight: 400;\">\/<\/span><span style=\"font-weight: 400;\">js<\/span><span style=\"font-weight: 400;\">\/<\/span><span style=\"font-weight: 400;\">model<\/span><span style=\"font-weight: 400;\">\/set-payment-information-mixin.js).<\/span><\/p>\n<pre class=\"lang:default decode:true \">\/**\r\n * Copyright &#169; Magento, Inc. All rights reserved.\r\n * See COPYING.txt for license details.\r\n *\/\r\n\/*global alert*\/\r\ndefine([\r\n    'jquery',\r\n    'mage\/utils\/wrapper',\r\n    'Magento_CheckoutAgreements\/js\/model\/agreements-assigner'\r\n], function ($, wrapper, agreementsAssigner) {\r\n    'use strict';\r\n\r\n    return function (placeOrderAction) {\r\n\r\n        \/** Override place-order-mixin for set-payment-information action as they differs only by method signature *\/\r\n        return wrapper.wrap(placeOrderAction, function (originalAction, messageContainer, paymentData) {\r\n            agreementsAssigner(paymentData);\r\n\r\n            return originalAction(messageContainer, paymentData);\r\n        });\r\n    };\r\n});\r\n<\/pre>\n<p>Before deploying JavaScript changes to production, remember to clear the cache and redeploy static content if required by your deployment workflow. Testing custom widgets and mixins across different storefront pages also helps ensure they behave consistently with other Magento components.<\/p>\n<h2>Summary<\/h2>\n<p>JavaScript is a very useful technology for ecommerce developers, yet it has one flaw &#8211; JavaScript elements tend to slow down the pages&#8217; loading, worsening your store&#8217;s performance. Defer JS for Magento 2 is a great tool to optimize your webstore &#8211; it moves JavaScript to the bottom of the page, deferring its par&#1089;ing and loading. This way, your customers will experience the pleasure of comfortable and fast online shopping.<\/p>\n","protected":false},"excerpt":{"rendered":"To give your online store a modern, smart look without globally altering the current design, &#8230;","protected":false},"author":82,"featured_media":19789,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"image","meta":{"_acf_changed":false,"footnotes":""},"categories":[491,389,473,524],"tags":[],"class_list":["post-19787","post","type-post","status-publish","format-image","has-post-thumbnail","hentry","category-magento-2","category-magento2-development","category-magento-front-end-developer","category-magento-speed-optimization","post_format-post-format-image"],"acf":[],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.4 - aioseo.com -->\n\t<meta name=\"description\" content=\"Learn how to use jQuery and requireJS in Magento 2. Create widgets and dynamic elements with JavaScript solution. Discover step-by-step instruction\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Andrey Litvin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/belvg.com\/blog\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.4\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html#article\",\"name\":\"How to Add Magento 2 jQuery & RequireJS in 2026 | BelVG Blog\",\"headline\":\"How to use jQuery and requireJS in Magento 2? 2026 JavaScript Solutions\",\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/Artboard-1-30.png\",\"width\":1108,\"height\":590,\"caption\":\"How to use jQuery and requireJS in Magento 2? JavaScript Solutions.\"},\"datePublished\":\"2019-03-07T14:50:15+02:00\",\"dateModified\":\"2026-07-08T10:54:00+02:00\",\"inLanguage\":\"en-US\",\"commentCount\":2,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html#webpage\"},\"articleSection\":\"Magento 2, Magento 2 Development, Magento Front End Developer, Magento Speed Optimization, Image\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development#listItem\",\"name\":\"Magento 2 Development\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development#listItem\",\"position\":2,\"name\":\"Magento 2 Development\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html#listItem\",\"name\":\"How to use jQuery and requireJS in Magento 2? 2026 JavaScript Solutions\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html#listItem\",\"position\":3,\"name\":\"How to use jQuery and requireJS in Magento 2? 2026 JavaScript Solutions\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development#listItem\",\"name\":\"Magento 2 Development\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin#author\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin\",\"name\":\"Andrey Litvin\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/e1a6e3c80cb940fddb65016d94b015cd951b4a8a9cd7227565131f28ea95c7a0?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Andrey Litvin\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html#webpage\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html\",\"name\":\"How to Add Magento 2 jQuery & RequireJS in 2026 | BelVG Blog\",\"description\":\"Learn how to use jQuery and requireJS in Magento 2. Create widgets and dynamic elements with JavaScript solution. Discover step-by-step instruction\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/Artboard-1-30.png\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html\\\/#mainImage\",\"width\":1108,\"height\":590,\"caption\":\"How to use jQuery and requireJS in Magento 2? JavaScript Solutions.\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html#mainImage\"},\"datePublished\":\"2019-03-07T14:50:15+02:00\",\"dateModified\":\"2026-07-08T10:54:00+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"How to Add Magento 2 jQuery & RequireJS in 2026 | BelVG Blog","description":"Learn how to use jQuery and requireJS in Magento 2. Create widgets and dynamic elements with JavaScript solution. Discover step-by-step instruction","canonical_url":"https:\/\/belvg.com\/blog\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/belvg.com\/blog\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html#article","name":"How to Add Magento 2 jQuery & RequireJS in 2026 | BelVG Blog","headline":"How to use jQuery and requireJS in Magento 2? 2026 JavaScript Solutions","author":{"@id":"https:\/\/belvg.com\/blog\/author\/andrey-litvin#author"},"publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2019\/03\/Artboard-1-30.png","width":1108,"height":590,"caption":"How to use jQuery and requireJS in Magento 2? JavaScript Solutions."},"datePublished":"2019-03-07T14:50:15+02:00","dateModified":"2026-07-08T10:54:00+02:00","inLanguage":"en-US","commentCount":2,"mainEntityOfPage":{"@id":"https:\/\/belvg.com\/blog\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html#webpage"},"isPartOf":{"@id":"https:\/\/belvg.com\/blog\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html#webpage"},"articleSection":"Magento 2, Magento 2 Development, Magento Front End Developer, Magento Speed Optimization, Image"},{"@type":"BreadcrumbList","@id":"https:\/\/belvg.com\/blog\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","position":1,"name":"Home","item":"https:\/\/belvg.com\/blog\/","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento2-development#listItem","name":"Magento 2 Development"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento2-development#listItem","position":2,"name":"Magento 2 Development","item":"https:\/\/belvg.com\/blog\/category\/magento2-development","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html#listItem","name":"How to use jQuery and requireJS in Magento 2? 2026 JavaScript Solutions"},"previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html#listItem","position":3,"name":"How to use jQuery and requireJS in Magento 2? 2026 JavaScript Solutions","previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento2-development#listItem","name":"Magento 2 Development"}}]},{"@type":"Organization","@id":"https:\/\/belvg.com\/blog\/#organization","name":"BelVG Blog","description":"Magento and Prestashop articles","url":"https:\/\/belvg.com\/blog\/"},{"@type":"Person","@id":"https:\/\/belvg.com\/blog\/author\/andrey-litvin#author","url":"https:\/\/belvg.com\/blog\/author\/andrey-litvin","name":"Andrey Litvin","image":{"@type":"ImageObject","@id":"https:\/\/belvg.com\/blog\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/e1a6e3c80cb940fddb65016d94b015cd951b4a8a9cd7227565131f28ea95c7a0?s=96&d=mm&r=g","width":96,"height":96,"caption":"Andrey Litvin"}},{"@type":"WebPage","@id":"https:\/\/belvg.com\/blog\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html#webpage","url":"https:\/\/belvg.com\/blog\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html","name":"How to Add Magento 2 jQuery & RequireJS in 2026 | BelVG Blog","description":"Learn how to use jQuery and requireJS in Magento 2. Create widgets and dynamic elements with JavaScript solution. Discover step-by-step instruction","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/belvg.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/belvg.com\/blog\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html#breadcrumblist"},"author":{"@id":"https:\/\/belvg.com\/blog\/author\/andrey-litvin#author"},"creator":{"@id":"https:\/\/belvg.com\/blog\/author\/andrey-litvin#author"},"image":{"@type":"ImageObject","url":"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2019\/03\/Artboard-1-30.png","@id":"https:\/\/belvg.com\/blog\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html\/#mainImage","width":1108,"height":590,"caption":"How to use jQuery and requireJS in Magento 2? JavaScript Solutions."},"primaryImageOfPage":{"@id":"https:\/\/belvg.com\/blog\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html#mainImage"},"datePublished":"2019-03-07T14:50:15+02:00","dateModified":"2026-07-08T10:54:00+02:00"},{"@type":"WebSite","@id":"https:\/\/belvg.com\/blog\/#website","url":"https:\/\/belvg.com\/blog\/","name":"BelVG Blog","description":"Magento and Prestashop articles","inLanguage":"en-US","publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"}}]}},"aioseo_meta_data":{"post_id":"19787","title":"How to Add Magento 2 jQuery &amp; RequireJS in 2026 | #site_title","description":"Learn how to use jQuery and requireJS in Magento 2. Create widgets and dynamic elements with JavaScript solution. Discover step-by-step instruction","keywords":null,"keyphrases":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_custom_url":null,"og_image_custom_fields":null,"og_image_url":null,"og_image_width":null,"og_image_height":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_image_url":null,"twitter_title":null,"twitter_description":null,"schema_type":"default","schema_type_options":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null,"created":"2026-11-03 18:36:52","updated":"2026-11-03 18:36:52"},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/category\/magento2-development\" title=\"Magento 2 Development\">Magento 2 Development<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tHow to use jQuery and requireJS in Magento 2? 2026 JavaScript Solutions\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/belvg.com\/blog\/"},{"label":"Magento 2 Development","link":"https:\/\/belvg.com\/blog\/category\/magento2-development"},{"label":"How to use jQuery and requireJS in Magento 2? 2026 JavaScript Solutions","link":"https:\/\/belvg.com\/blog\/how-to-use-jquery-and-requirejs-in-magento-2-javascript-solutions.html"}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/19787","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/users\/82"}],"replies":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/comments?post=19787"}],"version-history":[{"count":10,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/19787\/revisions"}],"predecessor-version":[{"id":30762,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/19787\/revisions\/30762"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/media\/19789"}],"wp:attachment":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/media?parent=19787"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/categories?post=19787"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/tags?post=19787"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}