MWDelaney / bootstrap-3-shortcodes

WordPress shortcodes for easier use of Bootstrap elements in your content.
https://wordpress.org/plugins/bootstrap-3-shortcodes/
MIT License
377 stars 118 forks source link

Javascript assets loaded on the frontend #89

Closed bostondv closed 10 years ago

bostondv commented 10 years ago

There are two javascript assets from the plugin that are being loaded into the wp_footer on the front-end. includes/js/bootstrap-shortcodes-popover.js and includes/js/bootstrap-shortcodes-tooltip.js.

Since the plugin depends on Bootstrap being included in the theme, why do we need to load additional scripts and add these two http requests?

Or looking at the code... I wonder if these are meant for the wp-admin? If so, I think you should be loading them with admin_enqueue_scripts so they aren't loaded in the front-end.

Thanks for the great plugin!

simonyeldon commented 10 years ago

They are added as those two components require trigger functions.

On 6 Aug 2014, at 21:54, Boston Dell-Vandenberg notifications@github.com wrote:

There are two javascript assets from the plugin that are being loaded into the wp_footer on the front-end. includes/js/bootstrap-shortcodes-popover.js and includes/js/bootstrap-shortcodes-tooltip.js.

Since the plugin depends on Bootstrap being included in the theme, why do we need to load additional scripts and add these two http requests?

Or looking at the code... I wonder if these are meant for the wp-admin? If so, I think you should be loading them with admin_enqueue_scripts so they aren't loaded in the front-end.

Thanks for the great plugin!

— Reply to this email directly or view it on GitHub.

MWDelaney commented 10 years ago

See #51. These scripts are necessary for tooltip and popover to work as per Bootstrap's own documentation here and here.

Closing as well-answered.

bostondv commented 10 years ago

Thanks for pointing out the discussion, admittedly I didn't search through the issues before posting. Anyways, I see where you're coming from now.

Loading the scripts only when the associated shortcodes are used would be a nice addition that was discussed in the other thread.

Additionally, what about adding a filter to control whether the the scripts are loaded? This way a developer could disable the script loading in the case they don't need the two components or wish to initialize them within their own javascript files. — Boston

On Wed, Aug 6, 2014 at 8:54 PM, MWDelaney notifications@github.com wrote:

Closed #89.

Reply to this email directly or view it on GitHub: https://github.com/filipstefansson/bootstrap-3-shortcodes/issues/89#event-150042366

MWDelaney commented 10 years ago

These scripts should now be conditionally loaded only when the [tooltip] and [popover] shortcodes are in use on a given page. See here: c1131e00b13176947caeb0fbb4286a0605c2c68a