1. Home
  2. Docs
  3. WP VR
  4. Control Script And Style Loading For The Virtual Tours

Control Script And Style Loading For The Virtual Tours

You can control the WPVR scripts and styles to load only on the pages/posts where you’ve published a tour.

Follow these steps to control it.

Control Script And Style Loading

Step 1: 

Go to the Get Started page of WPVR and click on the Settings tab.

WPVR Home Page

This page will appear.

WPVR General Settings

Step 2: 

Go to the page/post on your website where you’ve published a virtual tour.

Copy the URL of that page/post.

Copy URL of Tour Page

Step 3: 

Now, go to the Settings section of WPVR.

On the bottom, you’ll find a named ‘Allowed pages to enqueue WP VR Scripts:‘.

Copy and paste the URL of your tour page or post in this field.

If you have multiple pages/posts with tours, copy the URLs one by one and paste URLs of multiple pages/posts in this field using commas (,) between them.

Suppose, you have two pages/posts with the URLs https://example.com/sample-tour-1/ and https://example.com/sample-tour-2/.

Keep it just like this: https://example.com/sample-tour-1/,https://example.com/sample-tour-2/

Don’t use any space between a comma (,) and an URL when you’re listing multiple URLs.

Scripts and Styles Settings

Turn on the Enable script control to load WP VR scripts on listed pages only option.

Click on the Save button.

From now, WPVR scripts and styles will be loaded only on the pages/posts where you have a virtual tour.

If you’re using any optimization plugin, you have to regenerate the optimized assets.

Suppose you’re using the plugin Autoptimizer, here is how you can do it:

Exclude WPVR JS Files From Autoptimizer

If you are using Autoptimizer, it will minify the JS files of WPVR and the tour will not show up.

So you have to exclude the plugin folders from the Autoptimizer.

Go to Autoptimizer and under CSS, JS, and HTML section, you’ll see the ‘Exclude scripts from Autoptimize:‘ field.

Exclude WPVR JS From Autoptimizer

If you’re using the free version of WPVR, add a comma (,) and include wp-content/plugins/wpvr.

If you’re using the pro version of WPVR, add a comma (,) and include wp-content/plugins/wpvr, wp-content/plugins/wpvr-pro.

Now scroll down and click on the Save Changes and Empty Cache button.

From now on, your virtual tours will show up on your site and the JS files of your website will still be optimized.

Exclude WPVR JS Files From SG Optimizer

If you are using SG Optimizer, it may minify the JS files of WPVR and the tour may not show up.

So, you can exclude the pages with virtual tours from optimization to avoid this issue.

Go to SuperCacher then choose Exclude URLs.

Exclude URLs from SG Optimizer

Copy the URLs of the posts or pages where you have published a virtual tour and paste it in this field.

You can list multiple URLs to exclude from being cached or optimized.

You can learn more about excluding URLs from SG Optimizer from here.