Bird
0
0

What will be the output if you enqueue a script with the handle 'my-script' twice with different URLs in the same hook?

medium📝 component behavior Q4 of 15
Wordpress - Theme Structure and Basics
What will be the output if you enqueue a script with the handle 'my-script' twice with different URLs in the same hook?
AWordPress will throw an error
BOnly the first script URL will be loaded
COnly the second script URL will be loaded
DBoth scripts will be loaded
Step-by-Step Solution
Solution:
  1. Step 1: Understand handle uniqueness in enqueuing

    WordPress uses the handle to identify scripts; duplicate handles overwrite previous calls.
  2. Step 2: Determine which script loads

    The first call registers the script; the second call with the same handle is ignored, so only the first URL loads.
  3. Final Answer:

    Only the first script URL will be loaded -> Option B
  4. Quick Check:

    Duplicate handle loads first script only [OK]
Quick Trick: Use unique handles to avoid conflicts [OK]
Common Mistakes:
  • Assuming both scripts load
  • Expecting an error on duplicates
  • Using same handle for different files

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes