I have seen script and style handles written in two different ways in wp_register_script
and wp_enqueue_script
(the same applies to wp_register_style
and wp_enqueue_style
):
wp_register_script( 'jquery-someplugin', $location );
wp_register_script( 'jquery.someplugin', $location );
#1 uses a hyphen, #2 uses a period. What is the best practice here?
Which should I be using?
Use hyphens only.
Take a look at
wp-includes/script-loader.php
:Yes, I copied a rectangle. 🙂
The unofficial naming scheme is: main library first, then package, then sub-package, all separated by hyphens.
If you follow this scheme – and other developers too! – you lower the risk to enqueue the same library as another plugin just with another name.
Unfortunately, even in core you can find exceptions:
'suggest'
and'schedule'
are using jQuery …