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.
1 Answer 1
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
- 
 thanks for your answer, but i still get mismatched error. Sometimes it works. Sometimes it does not work...SebastianT– SebastianT2020年04月28日 09:58:29 +00:00Commented 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...SebastianT– SebastianT2020年04月28日 10:02:43 +00:00Commented Apr 28, 2020 at 10:02
Explore related questions
See similar questions with these tags.