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.

asked Apr 28, 2020 at 9:05

1 Answer 1

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

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.