I searched a lot for something like this and it helped me a lot improving my plugins, so I am sharing it with Wordpress Plugins developers: http://wp.tutsplus.com/articles/quick-tip-improving-shortcodes-with-the-has_shortcode-function/
Like someone posted in the comments section, I don’t like parsing the whole content, it looks slowish.
This methos seems much better: http://scribu.net/wordpress/optimal-script-loading.html
Indeed, the method you indicated is better, thanks for sharing it!
- Microlancer Beta Tester
- Author had a File in an Envato Bundle
- Author was Featured
- Bought between 50 and 99 items
- Exclusive Author
- Has been a member for 3-4 years
- Item was Featured
- Sold between 100 000 and 250 000 dollars
Just write wp_enqueue_script inside the add_shortcode function, the script will get loaded at the end of the < body > if the shortcode has been called
All problems solved
