Swiss Knife Oxygen

Scripts Manager

Include Scripts and Styles in Oxygen websites with Swiss Knife. Crafted for Oxygen Builder with security in mind. Upload scripts and styles are enabled only when you need them.

Is disabled by default as all Swiss Knife features. To Enable Font Manager open the Swiss Knife Features page under Swiss Knife > Features. Activate Enable Scripts Manager feature, Hit Save. After you saved preferences you need to refresh the page to see Scripts Managers Page.

Add Script or Style

Open Swiss Knife > Scripts Manager > + Add New Script

Hit + Add New Script button

Example of Script/Style card with all available settings

Script name

This field is used for two reasons. One is to help you find script in scripts list. Second is to generate enqueue code.

Script Type

Choose option is between JavaScript or CSS.

If your file have extension .js select JavaScript and if your file have extension .css use CSS from drop down

Script Location

Best practice is to register .CSS in header (before body) and .JavaScript in the footer (after body).

Reason behind it is that you want you elements inside body to be styled with CSS as soon as possible. JavaScript you want in footer as you probably want that page is rendered first before user start interacting what page.

Include Type

Enqueue

With this option, the script will be included on every page of your website. This is useful if you are including CSS such as framework or main theme JavaScript and there you have a toggle for navigation and you will definitely need that your navigation to work on every page.

Register

When you register a script, it will be ready for the website but it will not be triggered and displayed on the website until you tell your script on the page or the template.

To do that you can copy the trigger code in two locations. You can find the copy option close to the edit button when the card is in the collapsed state. When the card is in the expanded state, you will find “Click to copy” text in a grey block.

The copied code can now be pasted inside a code block on the Pages or Template Pages where you want that script to be triggered.

Note: you can paste it even in reusable element. If you have the same wp_enqueue_script(‘script_name’); several times on the page, it will still call that script only once without any errors.

Frontend Only

This option is for scripts that you don’t need inside Oxygen Builder and only on frond-end. A typical use case is when you don’t want animation scripts inside oxygen, but you need your Frameworks CSS to be rendered everywhere.

Upload file

In this field, it’s possible to paste scripts and styles that are either self-hosted or from a CDN. Paste CDN script inside input field or use WordPress media uploader by selection arrow up.

Allow Scripts and Styles upload

By default, uploading of Scripts and Styles in WordPress is not allowed and you will get an error if you try to do so.

You need to go to Swiss Knife features and Allow CSS/JS Uploads. For best practices and security reason use this option only in local setup or enable it only during scripts upload. Disable it after you finished process.