CMS Development

gsantos1
Contributor

js uploaded in Design Manager returns Uncaught SyntaxError

Hello

I'm trying to solve this for sometime now.

 

I uploaded the fancybox.umd.js on my site template folder in Design Manager. I tried to load with 2 different methods, both return the same error:

 

{{ require_js(get_asset_url("/THEMENAME/js/fancybox.umd.js")) }}

or

<script src="{{ get_asset_url('/THEMENAME/js/fancybox.umd.js') }}"></script>

 

Uncaught SyntaxError: unexpected token: ')'

 

It only works loading from fancybox CDN, but I want to avoid add another domain to the site loading because of performance, so I need to load from my domain.

 

Has you seen this before?

0 Upvotes
3 Replies 3
Syeda_Fatima
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

js uploaded in Design Manager returns Uncaught SyntaxError

Hey @gsantos1 yes, and I would suggest you to try loading the script with the async attribute set to true. This will allow the script to load without blocking the rest of the page.

 

<script src="{{ get_asset_url('/THEMENAME/js/fancybox.umd.js') }}" async></script>

 

gsantos1
Contributor

js uploaded in Design Manager returns Uncaught SyntaxError

Hi @Syeda_Fatima 

 

I had async there before, I removed to make the line as simple as possible trying to solve the issue, no success.

 

Even if I use the full URL from my theme instead of get_asset_url, the issue persist.

 

Uncaught SyntaxError: unexpected token: ')'

 

and the same file loading from outside Hubspot, loads fine.

 

Maybe is something to do with the minifying process on Hubspot?

0 Upvotes
Syeda_Fatima
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

js uploaded in Design Manager returns Uncaught SyntaxError

Dear @gsantos1I'm not sure what is causing the issue. It could be related to the minifying process, or it could be related to the way the file is being loaded.

 

However, You could try loading the file directly from your theme instead of using the get_**bleep**et_url() function to see if that makes any difference.

 

And also, you could try debugging the code to see why the syntax error is being thrown.

0 Upvotes