• Resolved Sajid Manzoor

    (@sajiddesigner)


    Hello
    I have a site built using DIVI theme. This website have external widgets embedded into website. These widgets are emebedded into pages using a JS file and an iframe.

    Example code widget embed is:

    <script src="https://www2.pathToJS.com/inc/pcrframehost.js"></script><link rel="stylesheet" href="https://www2.pathToCSS.com/pcrframehost.css"><iframe frameborder="0" host="https://www2.pathToiFrame.com/pcrbin/reg5.aspx?username=PUBLIC&p2=&action=SEARCH&" id="pcrframe" name="pcrframe" src="about:blank" style="height:640px;width:100%;background-color:transparent;border:0;margin:0;padding:0" onload="pcrframeurl();"></iframe>

    Now if i enable minify and combine JS files in SG optimizer settings then it breaks the iframe and in console it shows an error

    ‘Uncaught ReferenceError: pcrframeurl is not defined at HTMLIFrameElement.onload ((index):161)’

    I need to exclude URL https://www2.pathToJS.com/inc/pcrframehost.jsv from minifying and combining. I have checked in SG optimizer settings and there i can only exclude files which are added using WP_Enqueue.

    Kindly suggest solution or add support for excluding external URLS is coming update.

    Thank you
    Sajid

Viewing 1 replies (of 1 total)
  • Plugin Author Stoyan Georgiev

    (@stoyangeorgiev)

    Hey there @sajiddesigner,

    You can exclude external scripts from being combined using the filter we’ve designed for that purpose. Here’s an example of the code, you can add to your functions.php file where script-host.com has to be replaced with the URL you need to exclude:

    
    add_filter( 'sgo_javascript_combine_excluded_external_paths', 'js_combine_exclude_external_script' );
    function js_combine_exclude_external_script( $exclude_list ) {
        $exclude_list[] = 'script-host.com';
    
        return $exclude_list;
    }

    Kind regards,
    Stoyan

Viewing 1 replies (of 1 total)
  • The topic ‘Exclude external URLs from Combine JS & Minify JS’ is closed to new replies.