Whether you use our WordPress Mediavine Control Panel plugin or insert it manually, our script wrapper is the crucial first step toward placing ads on your site.
What It Does
The bulk of our script wrapper is just a collection of settings specific to your Mediavine dashboard. That means that any dashboard settings you adjust, and any settings defined at the admin level, will be reflected in our script wrapper.
It then uses minified code to call various scripts that contain the logic that does all the heavy lifting to run the real-time ad auction and determine ad placement. This process also only loads scripts that contain necessary functionality on your site to prevent any unused code being added to your site.
What this all means is the script wrapper is as lightweight as it can possibly be and ensures the only scripts that load are tailored to your specific ad setup.
What Can Be Done To Ensure It Runs Optimally
If you're on WordPress and using the Mediavine Control Panel plugin (coming soon to PubNation), the good news is, it's already doing all the work for you. After you've inserted your unique site ID, our plugin will place the script wrapper in the optimal spot in your site's head.
If you're on Blogger or Squarespace, we recommend following the linked help articles to get the script wrapper placed on your site.
If you're not on any of those platforms, our recommendation is to copy the script tag from the Ad Setup section of your Mediavine dashboard and insert it into the head element of your site:
If you're able to pick the exact spot in the head to insert this script wrapper, our only recommendation is to insert it midway or toward the end of the head. We have found that placing it too far at the top can lead to it working improperly.
How Can the Script Wrapper Be Optimized Further
The simplest answer is that it is already fully optimized and any attempts at additional optimization can impact ad performance. Attempts to further defer, delay, minify, or modify have led to our script not working as intended or not functioning at all. The simplest and most stable way to ensure your script wrapper is working as intended is to make no additional adjustments.
If you're on WordPress and you are running a plugin that improves site speed by optimizing scripts, we recommend looking at their help documentation for ways to exclude our script from its optimization. WP Rocket is one of the larger optimization plugins available and they exclude our script from optimization by default, but for other plugins, you may need to consult their documentation or reach out to their support team for assistance.