Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught SyntaxError: Unexpected token < #33

Closed
vincerubinetti opened this issue Aug 1, 2014 · 12 comments
Closed

Uncaught SyntaxError: Unexpected token < #33

vincerubinetti opened this issue Aug 1, 2014 · 12 comments

Comments

@vincerubinetti
Copy link

Can anyone think of any reason I would be getting such output from gif.js?

spawning worker 0 gif.js:1
spawning worker 1 gif.js:1
starting frame 1 of 201 gif.js:1
starting frame 2 of 201 gif.js:1
Resource interpreted as Script but transferred with MIME type text/html: "file:///C:/Users/Vincent/Desktop/Software/Tools/Gyrographer/App/gif/". gif.js:1
Uncaught SyntaxError: Unexpected token <

@jnordberg
Copy link
Owner

Probably due to you running it from disk instead of a web server

@vincerubinetti
Copy link
Author

Not the case. Thank you for the prompt response, and I apologize for the lack of detail. Was writing this very late at night and exhausted.

See here: http://vincentrubinetti.com/apps/test/Gyrographer.html Press "Export Animated GIF" and look in the console.

Here's my set up:

animate step function
{
animate step++
draw new canvas
add frame with gif.js
if animate done
{
render gif.js
}
else
{
setTimeout this step function 10 ms
}
}

It might have something to do with the htaccess... I'll fool around with that.

@jnordberg
Copy link
Owner

You need to set the workerScript url if it's not in the same dir as the page

@vincerubinetti
Copy link
Author

I did:

encoder = new GIF({width: Canvas.width, height: Canvas.height, workers: 2, quality: 10, workerScript: 'App/gif'});

Does it have to be an absolute path?

@jnordberg
Copy link
Owner

it needs to be a url to the actual script, not the directory it resides in

@vincerubinetti
Copy link
Author

Very good, got it working. Thank you! Perhaps you should make that clear in the workerScript description in the readme to avoid future confusion.

@jnordberg
Copy link
Owner

It's pretty clear already IMHO

@ionull
Copy link

ionull commented Mar 7, 2017

@jnordberg Is there any suggestion to use it in a webpack project(like vuejs), since it is a one-js-file project.

@jnordberg
Copy link
Owner

@ionull No, not really. The worker script is loaded through the browsers loading system, maybe that can be monkeypatched to do something but i doubt it.

@ionull
Copy link

ionull commented Mar 7, 2017

@jnordberg I found something like worker-loader workerjs project which will load worker from file. But in gif.js project we must use a file path instead of worker instance.

@1j01
Copy link

1j01 commented Mar 7, 2017

See #58, #47; @ZigGreen was able to load the worker with a blob URL.
You could use webpack-contrib/raw-loader or similar to dynamically inline the file in the resulting bundle.

@ionull
Copy link

ionull commented Mar 7, 2017

@1j01 thanks a lot, I used file loader minutes ago, it is now working well :) Blob is not compatible well with some IE browser

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants