Page 1 of 1

Can I include CSS and JavaScript files on specific pages?

Posted: 02 Jul 2025, 04:33
by TristanJo
Hi~~~~ :grinning:

Is there a way to set js or css to be loaded only on specific pages?

Re: Can I include CSS and JavaScript files on specific pages?

Posted: 02 Jul 2025, 10:38
by mjau-mjau
There are a few ways to achieve this, depending on your requirements.

1. Page Settings > Page > Advanced > Page Javascript.
Here you can add per-page Javascript.
Image

2. Or just go to the Page > Settings > Content, and paste your Javascript for the page where you want to use it.
Code
<script scr="myjavascript.js"></script>
3. Load the Javascript globally into Settings > Custom > Custom Head, and then just trigger your functions depending on the page, or if there are certain elements or classes in the page.

4. Similar to 3, Settings > Custom > Custom Javascript, add the javascript globally, and trigger it from x3_load_page(). Then you can use certain page cues, elements, or classes to decide if the script should trigger. Or even just create an array of page url's you want it to trigger for.