DEV Community

Cover image for How to Load Non-Minified Google Publisher Tag (GPT) Scripts on Production Using Requestly
Requestly
Requestly

Posted on • Originally published at requestly.com

How to Load Non-Minified Google Publisher Tag (GPT) Scripts on Production Using Requestly

Introduction

When troubleshooting or optimizing your ad setup, having access to a non-minified version of the Google Publisher Tag (GPT) scripts can be invaluable. Non-minified scripts are easier to read and debug, allowing you to understand how the code operates in your production environment. Requestly makes it simple to load non-minified GPT scripts on production without altering your site’s core code.

In this post, I’ll show you how to configure Requestly to replace the minified GPT scripts with their non-minified versions on production.

Why Use Requestly?

Requestly is a versatile tool that enables you to modify, redirect, and insert scripts into HTTP requests and responses. It’s especially useful for testing, debugging, and ensuring consistency across different environments. By using Requestly to load non-minified GPT scripts on your production site, you can easily debug issues and optimize performance without disrupting your live environment.

Setting Up Non-Minified GPT Script Loading with Requestly

1. Install Requestly

Begin by installing the Requestly extension from the Chrome Web Store or Requestly’s official website. After installation, the Requestly icon will appear in your browser.

2. Set Up a Redirect Rule

The Redirect Rule in Requestly allows you to redirect requests for minified scripts to their non-minified counterparts. This is particularly useful for loading readable, non-minified GPT scripts in your production environment for debugging and optimization.

Image description
Here’s how to set up a redirect rule for GPT scripts:

  1. Open Requestly: Click on the Requestly icon in your browser.
  2. Create a New Rule: Click on 'New Rule' and select 'Redirect Rule.'
  3. Enter the Minified Production URL Pattern: Add the URL pattern for the minified GPT scripts used in your production environment. This tells Requestly which requests to redirect.
  4. Specify the Non-Minified URL: Enter the URL for the non-minified version of the GPT scripts. This URL will be the target of the redirect.
    • Example Minified URL: https://example.com/gpt.min.js
    • Example Non-Minified URL: https://example.com/gpt.js
  5. Save the Rule: Click ‘Save’ to create the rule and ensure the rule is activated by toggling the switch to the 'On' position.

Conclusion

Using Requestly to load non-minified GPT scripts on production is a great way to gain insights into your ad code and troubleshoot issues more effectively. This approach allows you to work with readable, debuggable code in a live environment, making it easier to identify and resolve problems.

Explore More:

Top comments (0)