How to properly import external javascript file?

36 views Asked by At

In accordance with Home Assistant documentation, I should import external javascript files like below -

import "https://api-maps.yandex.ru/2.1/?apikey=1&module";

but when I do so I get the following error -

?lang=ru_RU&apikey=1&module:1 Uncaught TypeError: Cannot read properties of undefined (reading 'performance')
at ymapsInit (?lang=ru_RU&apikey=1&module:1:84)
at ?lang=ru_RU&apikey=1&module:1:28837

the error leads to the following code -

(function ymapsInit(e) {
    var n = this
      , t = {
        ns: {},
        supports: {},
        env: e
    };
    t.performance = {
        now: n.performance && n.performance.now ? n.performance.now.bind(n.performance) : function() {
            return Date.now()
        }
    },

Since this is external code, I can not modify it. Here is the working example of the same code, but not within Home Assistant.

How could I fix it?

0

There are 0 answers