Adding CDN player.js to a page which already has require.js on it will fail
See original GitHub issueExpected Behavior
player.js is instantiated without any problems and videos play happily.
Actual Behavior
The define functions clash with the already instantiated RequireJS.
Steps to Reproduce
- Load a copy of RequireJS. Having it actual resolve dependencies is unnecessary for issue reproduction.
- Later, include the CDN link to player.js in a script tag. This is done by a number of external libraries.
- The summoned video will not play.
I have a quickly knocked-together pen: http://codepen.io/jodi/pen/qqbXxw
Apologies for all the script tags, it’s just for easy toggling so you can see the effects each setting/script has.
My suggestion is to provide either a separate player.iife.js or something for including via a script tag. Alternatively, maybe provide the iife version by default. Maybe I don’t have enough knowledge, but I don’t think the user would need the AMD or CommonJS module syntaxes when accessing it via a CDN.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:8 (2 by maintainers)
Top Results From Across the Web
require.js text plugin adds ".js" to the file name - Stack Overflow
I have two web servers: localhost:3000 - act as CDN and has all the static files: js, images, css and templates; localhost:3001 -...
Read more >RequireJS API
For example, this arrangement will fail randomly when the require.config path ... //my/shirt.js now has some dependencies, a cart and inventory //module in ......
Read more >RequireJS - Quick Guide - Tutorialspoint
RequireJS is a JavaScript library and file loader which manages the dependencies between JavaScript files and in modular programming.
Read more >Getting Started with Video.js - Video.js: The Player Framework
js CDN. Our friends at Fastly are nice enough to provide hosting for all the necessary files for Video.js on their content delivery...
Read more >Video.js - Make your player yours | Video.js
The world's most popular open source HTML5 player framework.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@bdougherty Not to my knowledge. UMD makes sense in most circumstances. I’m sure there’s a better solution than what I’ve proposed, but I couldn’t find one.
I’ve now had to fix a few Magento 2 sites which had included player.js via the CDN, so I’m assuming there are more of them out there too. My method has been to generate a custom build of player.js with the Rollup format option set to
iifeand use that instead.Perhaps just a note in the documentation suggesting doing the above would suffice!
Still struggling to get this to work with require.js & Magento 2…
Uncaught TypeError: Vimeo.Player is not a constructorrequirejs-config.js:
js file:
Seems correct to me. Do I need to change the player.js file?