#StackBounty: #magento2 #javascript #knockoutjs #requirejs-config.js How to load js file first in Magento 2

Bounty: 100

I’m using Magento 2 and I have a js file that was called like this:

default.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
      <referenceContainer name="after.body.start">
          <block class="VendorModuleBlockAjaxLoginJs" template="Vendor_Module::login-ajax.phtml" name="login.ajax" as="login.ajax" before="head.components" ifconfig="loginpopup/general/enabled" />
      </referenceContainer>
    </body>
</page>

login-ajax.phtml

<script type="text/x-magento-init">
{
    "*": {
        "vm/loginajax"    : <?php echo $block->getJsOptions(); ?>
    }
} 

requirejs-config.js

var config = {
    map: {
        '*': {
            'vm/loginajax': 'Vendor_Module/js/login-ajax'
        }
    }
};

Vendor_Module/js/login-ajax

define([
    'jquery',
    'mage/translate',
    'jquery/ui',
    'mage/validation/validation',
    'vm/mycustom'
], function ($, $t) 

the js file size is 3KB , i noticed the js file is rendered not at the very beginning, how can i set the priority so this js file will load first?


Get this bounty!!!

#StackBounty: #magento2 #requirejs #cookie #requirejs-config.js Cookiebot throwing console errors in Magento 2.3.4

Bounty: 100

I have added cookiebot script into head tag,

here is the script

https://consent.cookiebot.com/uc.js

After adding this script, I am getting are many console errors,

Uncaught Error: Mismatched anonymous define() module: function ( $ ) {

Tried contacting support, but could not succeed in that, please advise me how to resolve this error,

Thanks in Advance!!


Get this bounty!!!

#StackBounty: #magento2 #requirejs #requirejs-config.js Enable zoom feature in custom template in Magento 2

Bounty: 50

I am creating zoom feature on images in my custom template,

app/code/Vendor/Module/view/frontend/requirejs-config.js

var config = {
 paths: {
        'custom_zoom': 'Vendor_Module/js/jquery.zoom.js'
 },
shim: {
    'custom_zoom': {
        deps: ['jquery']    
    }
 }
};

and in app/code/Vendor/Module/view/frontend/templates/custom.phtml

 <style>        
  .contain { 
    position: fixed; 
    right: 15%; 
    top: 15%; 
    width: 200px; 
    height: 220px; 
}       
</style>
<img class="imgsrc" src="image url here" />

<div class="contain"></div> 

<script type="text/javascript">
require(['jquery', 'jquery/ui','custom_zoom'], function($){ 
$(document).ready(function(){
    $('.imgsrc') 
        .parent() 
        .zoom({ 
            magnify: 4, 
            target: $('.contain').get(0) 
        }); 
 }); 

Moved jquery.zoom.js into Vendor/Module/view/frontend/web/js directory

But I am getting this error in console in my custom page.

Script error for: custom_zoom

Can anyone help me on this please..


Get this bounty!!!