Screening Entry Level

How do you properly include CSS and JavaScript files in a WordPress theme or plugin? Why should you use the enqueue system instead of hardcoding tags?

Quick Tip

Explain the why: "The enqueue system handles dependencies and prevents duplicates. If two plugins both need jQuery, it loads once. Hardcoded script tags would load it twice and break things."

What good answers include

Use wp_enqueue_style() and wp_enqueue_script() hooked to wp_enqueue_scripts (frontend) or admin_enqueue_scripts (admin). Each asset gets a handle (unique name), source URL, dependencies array, version string, and media type (CSS) or footer flag (JS). The enqueue system prevents duplicate loading, manages dependencies automatically, and allows other plugins and themes to dequeue or modify assets. Never hardcode link or script tags — it causes duplicate loading, breaks dependency order, and prevents child themes from overriding. Strong candidates mention: wp_register_style/script for registering without enqueuing, wp_localize_script or wp_add_inline_script for passing PHP data to JavaScript, and using the $ver parameter for cache busting.

What interviewers are looking for

Baseline WordPress development skill. Candidates who hardcode script and style tags in header.php will create conflicts with plugins and child themes. Those who understand the enqueue system build compatible themes and plugins.

← All WordPress questions