0

I am developing a wordpress plugin and just came out with a problem with enqueue scripts.

I want to enqueue JQUERY UI (.js) and (.css) in my plugin.

  • Is it better to enqueue it from Google CDN or from Wordpress bundled?
  • If in a wordpress admin page there are 2 plugins active and both used JQUERY UI of different versions. Then will it be a conflict or problem?

I googled many pages and actually didn't still come with a perfect solution. Please share your experience and views regarding enqueue scripts in plugin.

2

The best practice is to actually enqueue from the bundled version since it has a handle, this avoids conflicts.

If 2 scripts are enqueued using the same handle, jquery-ui-core for example (default WP one) then only 1 script is loaded.

If 2 scripts are enqueued using different names then they will both be loaded.

This is especually true for scripts and CSS like jQuery-UI which include thier own hardcoded handles like #tabs which can cause problems with themes and other plugins.

In my opinion breaking a site is worse than having to load a few extra KB's.

  • Thanks..how will i load jquery ui css from wordpress bundled? I mean i can load wp_enqueue_script("jquery-ui-core"). but what about itz CSS loading? – Md Shahinur Rahaman Aug 10 '13 at 5:22
  • The only CSS included is for jquery-ui-dialog you will have to use your own, it's almost always better to create your own CSS with unique id and class names. – Wyck Aug 10 '13 at 7:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.