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

For legacy browsers (without modules) #309

Closed
clarkk opened this issue Apr 20, 2023 · 8 comments
Closed

For legacy browsers (without modules) #309

clarkk opened this issue Apr 20, 2023 · 8 comments

Comments

@clarkk
Copy link

clarkk commented Apr 20, 2023

When I try to use the legacy version without modules I get an error

<script src="/js/github/inorganik/countUp.js/countUp.withPolyfill.min.js" defer></script>

Error

caught SyntaxError: Unexpected token 'export' (at countUp.withPolyfill.min.js:1:6208)

Chrome Version 112.0.5615.86 (Officiel version) (64-bit)

@clarkk clarkk changed the title For legacy browsers For legacy browsers (without modules) Apr 20, 2023
@inorganik
Copy link
Owner

I checked and that file is an es6 module, doh. How are you trying to import countup?

@clarkk
Copy link
Author

clarkk commented Apr 20, 2023

Just as in 1997 like ;)

<script src="/js/github/inorganik/countUp.js/countUp.withPolyfill.min.js" defer></script>

Without any kind of module import

@inorganik
Copy link
Owner

inorganik commented Apr 20, 2023 via email

@clarkk
Copy link
Author

clarkk commented Apr 20, 2023

Lookinng forward to a fix. Browsers without ES6 support is still around

@inorganik
Copy link
Owner

@clarkk Please try using dist/countUp.umd.js following the usage instructions in the readme, and include the polyfill just by copying it from the root of this repo - requestAnimationFrame.polyfill.js. If that works for you, I think I will just discontinue countUp.withPolyfill.min.js. Let me know.

@clarkk
Copy link
Author

clarkk commented Apr 29, 2023

I just use umd without module and it works fine

<script src=".../countUp.umd.js"></script>

$('.anim-countup').each(function(){
	const anim = new countUp.CountUp(this, $(this).data('count'), {
		duration: 3,
		separator: '.',
		decimal: ',',
		easingFn(t, b, c, d){
			const ts = (t /= d) * t, tc = ts * t;
			return b + c * (tc + -3 * ts + 3 * t);
		}
	});
	if(!anim.error) anim.start();
	else console.error(anim.error);
});

@inorganik
Copy link
Owner

Great! Here's what the dist folder will look like after my change in #311

dist/
├─ countUp.d.ts
├─ countUp.js
├─ countUp.min.js
├─ countUp.umd.js
├─ requestAnimationFrame.polyfill.js

so you'll just need to include the umd file and polyfill separately.

@inorganik
Copy link
Owner

This was merged and released in v2.6.1.

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

2 participants