0

We are trying to create new Theme in Magento2. We have a problem in executing third party js file.

requirejs-config.js file configuration

var config = {

  deps: [
    "js/default"
  ],
  paths: {
        'progress': 'js/progressively.min',
        'header': 'js/header',
    } ,
    shim: {
        'progress': {'deps': ['jquery'],'exports':'progressively'},
        'header': {'deps': ['jquery','progress']},
    }

};

I have downloaded the progreessively.min.js from the following Link https://cdnjs.com/libraries/progressively

header.js file

require([
    'jquery',
    'js/progressively.min'
], function ($) {
    "use strict";

    progressively.init({
        onLoadComplete: function() {
            console.log('All images loaded!');
        }
    });
});

We are loading the theme and content with no errors and there is also no error in console as well but js is not working. Can you please suggest us.

1

1 Answer 1

1

I found the solution. I have changes header.js file to below

header.js

require([ 'jquery', 'progressively' ], function ($,progressively) { 
    "use strict";
    progressively.init(
        { onLoadComplete: function() {
            console.log('All images loaded!');
        }
    });
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.