#3121·shepherd

[Question] Demo: Shepherd is not defined

Author: GuiloufCreated Feb 4, 2025Updated Feb 6, 2025
Labelsquestion

I'm not a power user of js, for the least. But in the the "demo", Shepherd module is imported in a script tag: index.html

<link rel="stylesheet" href="shepherd.js/dist/css/shepherd.css"/>
<script type="module" src="shepherd.js/dist/shepherd.mjs"></script>
<script src="demoScript.js"></script>

When imported like this, there is an error in the demo script, Shepherd is not defined.

For the example to work, i had to do differently: index.html

<link rel="stylesheet" href="shepherd.js/dist/css/shepherd.css"/>
<script type="module" src="demoScript.js"></script>

demoScript.js

import Shepherd from "shepherd.js/dist/shepherd.mjs"

const tour = new Shepherd.Tour({
		defaultStepOptions: {
			cancelIcon: {
				enabled: true
			},
			classes: 'class-1 class-2',
			scrollTo: { behavior: 'smooth', block: 'center' }
		}
	});
//........

Question are, what did I miss, and how it is supposed to work with this import: <script type="module" src="shepherd.js/dist/shepherd.mjs"></script> ? I think a jsfiddle would be much more didactic than the current demo page.