Recall & Review
beginner
What is the purpose of enqueuing styles and scripts in WordPress?
Enqueuing styles and scripts ensures that CSS and JavaScript files are loaded properly and only once. It helps avoid conflicts and improves site performance by managing dependencies and load order.
Click to reveal answer
beginner
Which WordPress function is used to add a CSS file to your theme or plugin?
The function
wp_enqueue_style() is used to add CSS files safely to your WordPress theme or plugin.Click to reveal answer
beginner
How do you properly add a JavaScript file in WordPress?
Use the
wp_enqueue_script() function inside a hook like wp_enqueue_scripts to add JavaScript files safely and manage dependencies.Click to reveal answer
intermediate
Why should you use hooks like
wp_enqueue_scripts when enqueuing files?Hooks like
wp_enqueue_scripts ensure your styles and scripts load at the right time during page rendering, preventing errors and conflicts.Click to reveal answer
intermediate
What parameters does
wp_enqueue_style() accept?It accepts: a handle (unique name), the URL of the CSS file, an array of dependencies, a version number, and the media type (like 'all' or 'screen').
Click to reveal answer
Which hook is commonly used to enqueue styles and scripts in WordPress?
✗ Incorrect
The
wp_enqueue_scripts hook is the standard hook to enqueue styles and scripts for the front end.What function do you use to add a JavaScript file in WordPress?
✗ Incorrect
Use
wp_enqueue_script() to add JavaScript files properly.Why should you avoid hardcoding <script> or <link> tags directly in theme files?
✗ Incorrect
Hardcoding can cause conflicts and duplicate loading; enqueuing manages these issues.
Which parameter in
wp_enqueue_style() defines the CSS file dependencies?✗ Incorrect
The
deps parameter is an array listing other styles that must load first.What does the 'version' parameter in
wp_enqueue_script() help with?✗ Incorrect
The version helps browsers know when to reload the script instead of using a cached copy.
Explain how to properly enqueue a CSS file in a WordPress theme.
Think about the function and the hook used.
You got /3 concepts.
Why is it important to use WordPress functions to enqueue scripts instead of adding them directly in header or footer?
Consider what problems direct inclusion might cause.
You got /5 concepts.