Jump to content
Search Community

Smooth Scroller error in Wordpress install

Shawn Williams test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Hi, I have added SmoothScroller to my wp installation and I can see that the files are loaded, however I'm getting the below error.

 

Uncaught SyntaxError: Unexpected token 'export' (at ScrollSmoother.js?ver=6.0.1:85:1)

 

When looking at the smoothscroller.js file, if I comment out the /*#__PURE__*/  in the line where the error is being generated the error goes away but SmoothScroller still will not load when checking with window.SmoothScroller in the console.  Is this comment the issue or am I missing something in the installation?

export var ScrollSmoother = /*#__PURE__*/function () {

This is my current set up from what I found in the forums, any help is greatly appreciated.

 

// The proper way to enqueue GSAP script
// wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );
	function theme_gsap_script() {
		wp_enqueue_script( 'gsap-js2', 'https://cdnjs.cloudflare.com/ajax/libs/gsap/3.10.4/gsap.min.js', array('wp-mediaelement'), false, true );
		wp_enqueue_script( 'gsap-st', 'https://cdnjs.cloudflare.com/ajax/libs/gsap/3.10.4/ScrollTrigger.min.js', array(), false, true );
		wp_enqueue_script( 'gsap-smoother', get_stylesheet_directory_uri() . '/node_modules/gsap/ScrollSmoother.js', array(), false, true );
	}
	add_action( 'wp_enqueue_scripts', 'theme_gsap_script' );

 

Link to comment
Share on other sites

  • Solution

Hey @Shawn Williams. Thanks for being a Club GreenSock member!

 

It looks like you're loading the ES Module file directly into a web page that isn't expecting a module. You should just use the minified file which is what the browser understands. In your download zip, there's a "minified" folder - use the file from there. Drop that on your server. It should be named ScrollSmoother.min.js. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...