Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vimeo is not defined

Tags:

jquery

ajax

I have this errors in console.log.

jQuery.Deferred exception: Vimeo is not defined ReferenceError: Vimeo is not defined
    at HTMLDocument.<anonymous> (http://unisoft.local/js/scripts.min.js:1:18238)
    at j (http://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:2:29999)
    at k (http://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:2:30313)

Uncaught ReferenceError: Vimeo is not defined
    at HTMLDocument.<anonymous> (scripts.min.js:1)
    at j (jquery.min.js:2)
    at k (jquery.min.js:2)

The code is: js file:

var vimeoBanner = $('#vimeo-banner');

    if (vimeoBanner[0]) {
        var vimeoPlayer = new Vimeo.Player(vimeoBanner[0]);
        vimeoPlayer.setVolume(0.2);
        vimeoPlayer.setLoop(false);
        if (firstVisit) {
            vimeoPlayer.play();
        }
    }

and html:

<div class="video-banner">
    <div class="video-banner__video">
        <iframe id="vimeo-banner" src="https://player.vimeo.com/video/217894047?color=02b4b6" width="640" height="360"
                allowfullscreen></iframe>
    </div>

Can someone help me please, I tried already to change the order of script files and it didn't work? Thanks.

like image 769
Jovana Babić Avatar asked Dec 03 '25 20:12

Jovana Babić


1 Answers

The variable/class is being used before it is declared. This library needs to be completely loaded first. Using the class inside a function that waits for the page to finish loading and putting the reference to the library in the header should do the trick.

like image 63
Miles Exner Avatar answered Dec 05 '25 10:12

Miles Exner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!