Naming script handles right way

I was wondering is there any convention or what is the right way for naming handles in wp_register_script() and wp_register_style() functions?

For example if I am developing a plugin that uses modernizer, is it better simply naming it ‘modernizer’ or something unique like ‘my-script-modernizer’?

If it is better to have unique handles and I am developing multiple plugins and I’m sure all uses same script. Should I use same handle in all plugins?

1 Answer
1

This question does to a degree solicit opinionated answers, but I feel it’s a good one nonetheless.
As far as my opinion goes and the way I handle things is this:

Definitely use the same handle for the same script in all your plugins and/or themes. You don’t want to load exact duplicates, if two of your plugins are used in the same WP install.

I give a generic handle to widely used and renowned scripts such as modernizr. Why should such a script be loaded more than once, under different handles?
I prefix handles of my own scripts, for reasons of namespacing.

Leave a Comment