Js referencing builder 404 link on live site (but not draft)

Hi,

This feels like a bug to me.

I’m using a custom code object within a box. There’s some javascript in a script tag that I’m testing.
Everything works as intended in the editor however when I publish it, the builder object returns a 404.

I created a short video as well as the console from the builder editor.
It appears the error exists in the editor as well, but it runs correctly in my browser so it doesn’t return an error?

Am I understanding how this should integrate?

(PS I’m not a developer, just someone who knows a tiny bit of code so I apologize in advance if this is naive or not enough detail)

Thanks in advance,


Builder content link

Builder public api key
4d74977563e44093958fcbdf0acb9d10

Detailed steps to reproduce the bug
See video

Screenshots or video link

Code stack you are integrating Builder with
Shopify

Reproducible code example

Hi @Doortender!

Can you try either: 1) Adding a binding to the custom code block in the data tab to showIf Builder.isBrowser or 2) Move the JS from the custom code block to the content JS section in the data tab (within Builder.isBrowser). Let me know if this works! We also have a countdown template that you could use rather than the custom code block.

Hi Maddy,

Thanks for your response. Your suggestion worked (#1).

Just for my understanding, custom code blocks run server side but don’t reference an output unless it’s explicitly telling it it’s in a browser?

Is the main use of the custom code block to just run js logic?

Am I understanding that correctly?

Thanks,

David

(PS. I didn’t use the countdown template because I couldn’t figure out how to make it time relative to today’s date.)

Glad that worked! Custom code blocks will be run on the server, depending on the advanced options selected. If the custom code is doing something in the dom, you’ll want to do this only in the browser. Using a custom code block shouldn’t be the first option (instead you should try and use Builder’s built-in blocks), but if you have to use a custom code block, yes, JS or 3rd party code are main use cases.