The JS tab holds the JavaScript of your snippet.
Tip: write only the script body — no
<script>wrapper.
How the JS is loaded#
Saving the snippet writes its JavaScript to a file, which is loaded only on pages where the snippet is shown, in the footer. Once saved, the JS File URL field shows its address. To load it in the <head> or with extra files, see Scripts & Styles.
jQuery#
Whether the script is loaded after jQuery. WP Coder Pro has three options PRO:
| Option | Behaviour |
|---|---|
| Auto (default) | jQuery is loaded only when the code uses it — it writes jQuery, $(, $. or $[. |
| Always load | jQuery is always loaded first. Choose it when the code needs jQuery without writing it, e.g. it calls a jQuery plugin through another name. |
| Never load | jQuery is never added. |
WP Coder (free): a Disable jQuery checkbox. The script is loaded after jQuery unless you tick it — tick it for plain JavaScript, so pages don’t load jQuery just for this snippet.
Inline#
Prints the JavaScript in a <script> tag on the page instead of loading a file.
Attribute variables (
{{$name}}) are replaced only in Inline mode PRO, inserted in a JavaScript-safe (JSON-encoded) form — a Number is inserted unquoted.{{global.name}}is not replaced in JS. The free WP Coder prints inline JS without replacing placeholders.
const delay = {{$delay}}; // Number attribute
const label = {{$button_text}}; // Text attribute → "Sign up"
Minified#
| Option | What it does |
|---|---|
| none | The code is loaded as written. |
| Minify (default in Pro) | Removes whitespace and comments. |
| Obfuscate (default in the free WP Coder) | Minifies and packs the code. Packed code runs through eval(), so it fails under a Content Security Policy without 'unsafe-eval', and it can’t be read in the browser’s developer tools. Use it only if you need it. |
Attribute#
How the script file loads: none, defer or async.
Combine PRO#
Merges this snippet’s JS into one file per page, loaded in the footer with defer. The file depends on jQuery only when at least one snippet in it does. Each snippet’s code is separated safely, so scripts that work alone keep working together.
Combine and Inline can’t both be on. Combined files rebuild automatically; after a migration use Tools → Developer → Rebuild Combined Files.
Add NAV Comment#
Inserts a // NAV: marker for the clickable outline.
JS Help PRO#
A quick reference and the snippet’s attribute variables.
Tips#
- Wait for the page: with defer or in the footer the DOM is ready; with async use
document.addEventListener('DOMContentLoaded', …). - Scope your code to the snippet’s markup (
document.querySelectorAll('.my-widget')) — a snippet may be on the page more than once.