You need to use separate template file for your category. Take a look at Wordpress templates hierarchy, you will most likely need to use category-$slug.php
template. In this template file you will need to use regular wp_enqueue_xxx
functions to inject JS / CSS that you need for this particular category.
UPDATE: To be able to apply additional JS / CSS to posts that have certain category instead of category itself you need to use wp_get_post_categories()
function to retrieve list of categories for your post, then decide if you have required category in the list and if it is so - apply additional assets. It can look something like this:
// Assuming that we have ID of current post inside $postId variable
// that can be retrieved e.g from $postId = the_post()->ID
// or from global $post variable
//
// Also assuming that we have $slug variable that contains slug
// of the category, we need to apply additional JS / CSS to
//
// Example:
// $postId = 123;
// $slug = 'hairstyle';
$categories = wp_get_post_categories($postId);
if (is_array($categories) && array_reduce(array_filter(array_map('get_category', $categories), function ($category) {
/** @var \WP_Term $category */
return $category->slug;
}), function ($found, $category) use ($slug) {
return $found ?: $category === $slug;
}, false)) {
// ... Apply additional JS / CSS ...
}
Of course this code should reside into template that renders post e.g. in single.php