Skip to main content

Can I add custom JavaScript to blog builder posts?

Yes, through the Custom HTML block. The code is published exactly as written, so use it at your own risk.

Written by Julia

Yes. The Custom HTML block accepts any markup, including <script> tags, so you can add widgets, embeds, or your own JavaScript to a blog post. Add a Custom HTML block where you want the code to live and paste it into the block's HTML field.

<div id="countdown"></div><script>  document.getElementById('countdown').textContent = 'Sale ends soon!';</script>

Use it at your own risk

TinySEO does not sanitize the code you put in a Custom HTML block. In other words, we do not check, clean, or modify it in any way. It is published to your Shopify article exactly as you wrote it and runs in the browser of every visitor who opens the post.

That gives you full freedom, but it also means:

  • A mistake in the code can break the layout of the article or interfere with your theme's own scripts.

  • Only paste code you wrote yourself or that comes from a source you trust. A malicious script would run on your storefront with access to everything on that page.

  • We cannot debug or support third-party scripts. If a post looks broken, remove or hide the Custom HTML block first to rule it out.

Why the script does not run in the editor

For safety, the editor preview strips <script>, <iframe>, <object> and <embed> tags, and inline event attributes such as onclick. So your JavaScript will not do anything inside the editor, and iframe widgets (videos, forms, booking tools) do not show there either. This is expected. The code still publishes in full: open the published article on your storefront to test it.

Good to know

  • External scripts work too: <script src="https://..."></script>. Add defer so they do not slow down the page while it loads.

  • If your code needs styling, you can keep its CSS in the same block's Custom CSS field (Settings tab, Advanced group). Those rules stay scoped to the block, so they cannot clash with your theme.

  • Hiding the block in the editor removes the code from the published article as well, which makes it easy to switch a script off without deleting it.

Did this answer your question?