Questions tagged [requirejs]
Denotes questions related to require JS. RequireJS is a JavaScript file and module loader. It is optimized for in-browser use, but it can be used in other JavaScript environments.
527 questions
0
votes
0
answers
47
views
Magento 2 how to avoid loading of certain js files on checkout page via requirejs?
I want to load certain js files on all pages except checkout page.
How can I add a condition in requirejs-config.js file not to load js files when user is on checkout page?
In the code below, I want ...
0
votes
0
answers
160
views
Js files issue in production mode magento2.4.6-p3
Site is working fine in developer mode but when we put the site in production mode there are different files showing 404 in console and these seems default files of magento but the path of the file ...
2
votes
0
answers
72
views
How to integrate Google Pay library into website?
I'm trying to integrate Google Pay into my Cart page. But, I always get an error, it looks like this:
Uncaught Error: Script error for "https://pay.google.com/gp/p/js/pay.js" https://...
2
votes
0
answers
659
views
Magento 2 : Codazon Fastest Theme js not loading propperly
I Have Installed Codazon Fastest Theme on my Manto2 site.i am facing an issue with js loading.
here is my system configuration below.
magento version : 2.4.5
PHP: 8.0
theme: Codazon Fastest Theme
...
0
votes
1
answer
431
views
can anyone find out the error in this knockout js code
this is phtml file located in Namespace_ModuleName/view/adminhtml/templates/js_time.phtml
<div>
<h4>Current Time is:</h4><span id="time_show" data-bind="text: ...
0
votes
1
answer
73
views
Magento 2 - Two scripts have method with same name, how to call one specific of them
Situation
The method "test" does exist two times. If I call it while both scripts are required, then only the last one is getting called e.g. the one from test2.js
app/code/Company/Test/view/...
0
votes
1
answer
437
views
How can I resolve the JavaScript error after upgrade magenta from M 2.4.3 to 2.4.5 in Magento 2??
Here I upgrade Magento from 2.4.3 to 2.4.5 so getting a javascript error can anyone help me how can I resolve this error?
Can not find out what excatly issue
1
vote
1
answer
197
views
Magento 2: Use of map in RequireJs-config
Is anyone know the use of this 'custom' & when we need to use that?
var config = {
map: {
**'custom':** {
'@@@': '@@@',
'@@@': 'js/@@@'
...
0
votes
1
answer
219
views
How to add a JS library and a JS script that makes use of that library?
I'm trying to use Chroma library in Magento and so far I did the following two things:
Created a app/design/frontend/Vendor/Theme/requirejs-config.js with the following content:
var config = {
deps: ...
0
votes
1
answer
2k
views
Component sometimes not loading - "Failed to load the "Vendor_ModuleName/js/view/minitest" component in Magento 2
We are launching a Magento 2.4.2 site, and finding that the site will sometimes load all of its Javascript components and dependencies properly, but sometimes fails to load on the custom component. In ...
0
votes
2
answers
65
views
How to use Jquery lib in Magento 2
Platform: Magento2
I want to import and use 3nd Jquery library in my module. Eg: https://www.jqueryscript.net/other/SEO-friendly-jQuery-Infinite-Scroll-Plugin-Clever-Infinite-Scroll.html use to create ...
0
votes
0
answers
908
views
console error:Uncaught TypeError: require.config is not a function in magento2
Uncaught TypeError: require.config is not a function
at requirejs-config.js:18
at requirejs-config.js:19
at requirejs-config.js:757
(anonymous) @ requirejs-config.js:18
(anonymous) @ ...
0
votes
1
answer
268
views
Add Fancybox in Magento 2.4.3
First, I added these files to my custom theme:
app/design/frontend/Custom/mytheme/web/js/jquery.fancybox.min.js
app/design/frontend/Custom/mytheme/web/css/jquery.fancybox.css
Then I edited app/...
0
votes
1
answer
95
views
Detect IE11 browser and show cms block modal with phtml script tag
I have a modal that pops up when the site detects it's on IE11. The modal is in a cms block so that the client can edit it. I have created a reference container with a custom phtml and put the script ...
3
votes
3
answers
298
views
Magento 2 - New Tax rule page showing "require is not defined" error in console
When I try to add new tax rule I am getting "require is not defined" error in console which cause properly loading issue for Tax Rate, Customer Tax Class and Product Tax Class field (see ...
2
votes
1
answer
3k
views
how to create a mixin js in magento
in my case i want to add a mixing for just a single line but i can't achieve that
the parent js file is ==> web/vendor/magento/module-customer/view/frontend/web/js/model/customer/address.js
/**
* ...
0
votes
2
answers
2k
views
How to load slick carousel , or any other js file into magento 2?
I'm trying to load the slick carousel into my magento theme and it generates a huge error: "Uncaught Error: Mismatched anonymous define() module". I think it must be related to require js, ...
4
votes
0
answers
179
views
How to use Youtube Player API with jQuery in in Magento 2?
I'm using Magento 2.4 and i'm trying to use Youtube player API with jQuery in Magento 2 .phtml file like this first:
<script>
require(['jquery'], function($){
var tag = document....
0
votes
1
answer
619
views
How to access custom attributes from the current product in JavaScript?
I added the following in view/frontend/layout/catalog_product_view.xml:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:...
1
vote
1
answer
1k
views
Magento 2: using knockout components within a component
I am trying to render a new KO component within a existing KO template. I have a PackagePopup component which in the template, renders a PackageFfilter component. I would like to seperate the logic ...
2
votes
1
answer
1k
views
inheritance in knockoutJS components within magento 2's knockout framework
I have been experimenting with a custom module with KnockoutJs on the frontend in M2.
I've created two components: a ProductPackage and a ProductPackagePopop. Functionally, the ProductPackage triggers ...
0
votes
0
answers
160
views
Magento 2: Adding a Javascript library
I am trying to add an animation library called Sal, built on pure Javascript (Does not rely on jQuery). Maybe I am missing something, but I followed the instructions on adding via require-config, and ...
0
votes
1
answer
364
views
Magento 2 Uncaught TypeError: Constr is not a constructor when returning functions on Knockout Js
i'm trying to get functions from a JS file in a Knockou file, like this:
quote.js
define(['jquery', 'uiComponent', 'ko','Vendor_GetQuote/js/ajax-request'], function ($, Component, ko, ajaxrequest) {
...
0
votes
4
answers
683
views
Magento 2 - How to use jQuery3?
I try to include jQuery 3 to my project so I can use it on some CMS sites.
Attempt:
THEME = app\design\frontend\company\fresh\
THEME\web\js\jQuery\jquery-3.6.0.js
Copy pasted the code from here to ...
0
votes
0
answers
1k
views
Javascript mixin issues - base is not a constructor
I ran into an interesting issue while trying to create a mixin for a 3rd party JS script. I created the mixin in the normal way with my requirejs-config.js like this:
let config = {
config: {
...