When drafting a post, look for the <html>
button on the menu bar that allows you to format text with bold, italics, strikethrough, and more. Clicking this button will display the HTML code for your post. Simply add a script tag containing the desired JavaScript code, like so:
<script>
alert("Hello World!");
</script>
NOTE: The JavaScript functionality may only be visible to users when they visit your actual page, unless they click on an option to reveal additional content to improve load times in the feed.
EDIT: To apply the same JavaScript to all of your posts, consider adding it directly into the theme's HTML. Access the HTML editor through
Customize -> Edit HTML (of the theme) -> insert <script> at the bottom of body or merge with existing <script>
. Each post is identified by the class
.POST
, which can be used as a selector to target them individually. For reference on specific classes, refer to the Tumblr API documentation or utilize inspect element tool.
NOTE: Integrating the script into the theme will not impact posts displayed in user feeds. This modification only affects the appearance and behavior of the overall theme, not individual posts when viewed off-site.