Search code examples
javascriptwordpresswistia

Wistia videos in WordPress loading extra scripts and script tags in content


I have a page on my WordPress site that has many videos on it and am using Wistia for my them. With the embed code, it seems to be loading the ev-1 script once for each video on the page. It is a lot..! I assume there is a better way to embed the videos? Do I need to include the ev-1 script for every video.. or only once? Can I move this into the head or below content? Also, I'm not a fan of the javascript in the editor.

Note: I do not want to use the oembed for various other reasons.


Solution

  • When copying the embed code from within Wisita, it always includes the ev-1 script. You can load it once, and safely move it to the head or before closing body.

    Theres a plugin for WordPress that can help with this exact issue. My plugin - Marcus Hiles Wistia Shortcodes - allows you to use a simple shortcode to embed videos in posts. Best part is that it uses WP functions like wp_enqueue_scripts and wp_script_is(enqueued) to intelligently load all the required js assets...only once. It stacks them nicely before closing body tag, keeping script tags out of the content.