Jump to content
Search Community

PixiPlugin from CDN - Unexpected token 'export'

mirohristov test
Moderator Tag

Recommended Posts

I'm trying to use the pixi plugin with gsap from jsdelivr or cloudflare CDN and I'm having a hard time getting it work.

 

 

This is what I'm trying right now:

https://jsfiddle.net/kwbu5g6r/

<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.5.1/gsap.min.js"></script>

<script src="https://cdn.jsdelivr.net/npm/gsap@3.5.1/PixiPlugin.min.js"></script>

<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.5.1/PixiPlugin.min.js"></script>--> Doesn't work either

In the first case, gsap loads but PixiPlugin results in Unexpected token 'export'

In the second case even gsap doesn't load

 

It worked just fine with TweenMax from jsdelivr but not when updating to gsap.  

Any ide what I'm doing wrong? Maybe I need a different lib. Also, how do I only use jsdelivr and not cloudflare?

 

 

 

Thank you!

 

 

 

Link to comment
Share on other sites

That's because you're loading the wrong file - you're loading the ES Module :)

 

The browser-ready ES5 (regular, non-fancy ES Modules) files are in a /dist/ directory: 

https://cdn.jsdelivr.net/npm/gsap@3.5.1/dist/PixiPlugin.min.js

 

But why are you loading the main GSAP file from Cloudflare, and PixiPlugin from an entirely different place (JSDelivr)? I'd just stick with Cloudflare (same URL, just swap "PixiPlugin.min.js" for "gsap.min.js"):

https://cdnjs.cloudflare.com/ajax/libs/gsap/3.5.1/PixiPlugin.min.js 

 

<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.5.1/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.5.1/PixiPlugin.min.js"></script>

Better? 

  • Like 2
Link to comment
Share on other sites

Jack you rock my brother! :) This worked like a charm!

 

The reason I'm using jsdelivr is so that I can combine all the libs in one request. I just didn't know about using /dist instead of the module.

 

All my scripts look like this now and it works great:

 

<script src="//cdn.jsdelivr.net/combine/npm/jquery@3.5.1,npm/sammy@0.7.6,npm/animejs@3.2.0,npm/ion-sound@3.0.7,npm/pixi.js@5.3.3/dist/pixi.min.js,npm/pixi-filters@3.1.1/dist/pixi-filters.min.js,npm/gsap@3.5.1,npm/gsap@3.5.1/dist/PixiPlugin.min.js"></script>

 I tried using cdnjs.com to find the pixiPlugin there but was unable to find anything. Also, you may want to add the CDN link in the documentation here and explain the difference between module and non-module: https://greensock.com/docs/v3/Plugins/PixiPlugin 

It will make it easer for lost souls like myself :) 

 

Thanks a lot!

  • Thanks 1
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...