How to add custom JavaScript
to web pages in Setka
If you want to enhance your webpages’ front-end functionality by adding content sliders, image popups, accordions, tabs etc – you’ll need to use custom JavaScript on your site. Figuring out how to do it can be tricky, but with Setka’s Custom JS plugins you can build JavaScript features for your content any way you want.
Setka content customization options
As you might already know, Setka lets you add interactive design features without touching code, like animations, galleries, hotspots, and footnotes. But if you’d prefer to implement your design ideas to supercharge your content, now you can create your own JavaScript plugins for new, custom elements.
The new Custom JS plugins grant more granular control, and in this article, the steps below show you how to get started introducing these advanced features to your pages.
How it works
Custom JS unlocks your ability to build your own JavaScript-based logic above the Setka content. Basically, any functionality you can make by combining JavaScript and Setka-based HTML is possible, using Setka’s Custom JS feature:
- Build the JavaScript plugin
- Send your JavaScript plugin code for review to Tiny Support team
- Tiny Support team loads JavaScript plugin code to Setka CDN
- Add the JavaScript plugin to specific post by adding a data attribute with a plugin ID to the post content
When your plugins load, they manipulate the content based on your own JS logic, down to a fine-grained degree if needed.
The processes of launching the plugin on the page and uploading it to Setka CDN (if needed) are described below.
How to add Setka’s Custom JS plugin to your post
Make sure your JavaScript plugin code is loaded to Setka CDN
Use the instruction in our Help Center, to submit the plugin code for review. Tiny Support team will notify you when the plugin is loaded and ready for use.
Add a plugin for the particular post by adding
data-stk-plugin=”vendor–name–name@version.js” attribute to any HTML element of the post. Setka’s public.js script will load and initialize the plugin for this particular element.
EXAMPLE
Adding data-stk-plugin=”stk–content-slider–content-slider@0.5″ code will enable stk/content-slider@v0.5 plugin:
<div class=”stk-grid stk-stk-content-slider”
data-ce-tag=”grid”
data-stk-plugin=”stk–content-slider–content-slider@0.5″
>…</div>
Custom JS ready-to-use plugins
Simple spoiler plugin
stk/spoiler
Simple accordion plugin
stk/accordion
Content slider plugin
stk/content-slider
Content slider build of stk-grid components.
Current version: 0.5
How to enable the content slider plugin
- Add data-stk-plugin=”stk–content-slider–content-slider@0.5″ data attribute and “stk-stk-content-slider” class attribute to the grid holding the slides as shown below.
- Save and test out the slider functionality, and adjust the attributes as needed
LAYOUT HTML EXAMPLE (replace theme ID with yours)
Simple image lightbox plugin
stk/lightbox
Current version: 0.7
How to enable the image lightbox plugin
- Add data-stk-plugin=”stk–lightbox–lightbox@0.7″ attribute to the grid holding the images as shown below.
- Save the changes, and check on the lightbox behavior. Makes adjustments as needed.
LAYOUT HTML EXAMPLE (replace theme ID with yours)
Simple spoiler plugin
stk/spoiler
Here is the hidden content.
Current version: 0.6
How to enable the simple spoiler plugin
- Add data-stk-plugin=”stk–spoiler–spoiler@0.6″ attribute to the grid holding the toggle and the content elements as shown below.
- Save and see how the spoiler plugin works. Adjust the attributes if needed.
LAYOUT HTML EXAMPLE (replace theme ID with yours)
Simple accordion plugin
stk/accordion
Section 1
Section 1 content.
Section 2
Section 2 content.
Section 3
Section 3 content.
Current version: 0.2
How to enable the simple accordion plugin
- Add data-stk-plugin=”stk–accordion–accordion@0.2″ attribute to the grid holding the toggle and the content elements as shown below.
- Save, and test drive the accordion. Change the attributes as needed.
LAYOUT HTML EXAMPLE (replace theme ID with yours)
Taking the next step
Setka offers a vast amount of flexibility and customisation to create content with few to no design limits. Together with default tools, custom CSS, and custom JS components, you have the ability to create advanced design and animation types in no time without the risk of breaking code.
Learn more about custom JS plugins in Setka in our documentation.