Support » Plugins » Hacks » Using iFrames for Shortcode Content

  • toneburst


    I’m making a short code plugin to insert JavaScript-based content into a post. This content requires JavaScript code to run, and as I understand it, the normal way to do this would be to use wp_enqueue_script to add the scripts to the head or footer of each page (by ‘page’, I mean page of content, not specifically a WordPress Page).

    However, this means that the scripts will be called for every page, even if none of the posts on the page require the script. I’m wondering if it’s a good idea to use an iFrame for the inserted content, and have the embedded page call the script. That way, the script is only called when required. I can’t see any practical disadvantages at the moment, but I’d be very surprised if somebody else hadn’t thought of (and probably dismissed) this. I’d be very interested to know if anyone has any thoughts on the advantages or disadvantages of using this method over the enqueue_script one.



Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Using iFrames for Shortcode Content’ is closed to new replies.