0

What is the simplest way to add external js script like:
https://sandbox-geowidget.easypack24.net/js/sdk-for-javascript.js
on my page? I've created block which i render on my product page. But i get an error.
Error: Script error for: and also mismatch error. I've tried:
requirejs-config.js:

var config = {
    map: {
       '*': {
           'map' : 'https://sandbox-geowidget.easypack24.net/js/sdk-for-javascript.js'
       }
    }
};

also tried:

var config = {
     paths: {
        map: 'https://sandbox-geowidget.easypack24.net/js/sdk-for-javascript.js'
    }
};

then in my js file:

require(['map'], function () {
        window.easyPackAsyncInit = function () {
            easyPack.init({});
            var map = easyPack.mapWidget('map', function(point){
            });
        }
});

but i get above errors.

0

Check below code

requirejs-config.js:

var config = {
    map: {
        '*': {
            sdkjavascript: 'Vendorname_ModuleName/js/sdkjavascript'
        }
    }
};

save external js in below folder like

Vendorname/ModuleName/view/frontend/web/js/sdkjavascript.js

Then try in custom js

require([
  'sdkjavascript'], function () {
        window.easyPackAsyncInit = function () {
            easyPack.init({});
            var map = easyPack.mapWidget('sdkjavascript', function(point){
            });
        }
});

I hope this will help you

| improve this answer | |
  • thanks for your answer, but i still get mismatched error. Sometimes it works. Sometimes it does not work... – SebastianT Apr 28 at 9:58
  • I checked requirejs-config.js in my pub/static/.... and there is this file. It is also included in head tag... – SebastianT Apr 28 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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