coppermine-gallery.com/forum

Support => cpg1.5.x Support => cpg1.5 miscellaneous => Topic started by: SirMoo on November 16, 2013, 11:53:33 AM

Title: Javascript Files - HTTP_PULL CDN
Post by: SirMoo on November 16, 2013, 11:53:33 AM
Let me preface this with I hate asking questions and normally prefer to figure out things on my own... But hours of searching haven't helped. :(

I use a CDN for my website with US/EU nodes to reduce some of the load on the server. One of the things it does is use HTTP_PULL to cache the Javascript files. Since Javascript on CPG is loaded using the {JAVASCRIPT} token... this makes it harder to modify the code to use the CDN and no the local copies. That being said I've resorted to editing functions.inc.php to do this. I don't really like doing such as I'm editing core files and that's rarely a good idea...

Is there a way to modify the theme files (theme.php) and change the Javascript Token to do the same thing I've done with the functions.inc.php file... Or am I just stuck editing the functions file?

I'm using version 1.5.20

function js_include($filename, $inline = false)
{
    global $JS;

    // Proceed with inclusion only if the file exists
    if (!file_exists($filename)) {
        return;
    }

    // If we need to show the html inline then return the required html
    if ($inline) {
        return '<script type="text/javascript" src="[domain-goes-here]' . $filename . '"></script>';
    } else {
        // Else add the file to js includes array which will later be used in head section
        $JS['includes'][] = $filename;
    }
} // function js_include
Title: Re: Javascript Files - HTTP_PULL CDN
Post by: ΑndrĂ© on November 21, 2013, 01:39:15 PM
You can always use the plugin hook page_html to modify HTML output before it will be sent to the browser.