Javascript Files - HTTP_PULL CDN Javascript Files - HTTP_PULL CDN
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Javascript Files - HTTP_PULL CDN

Started by SirMoo, November 16, 2013, 11:53:33 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

SirMoo

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

ΑndrĂ©

You can always use the plugin hook page_html to modify HTML output before it will be sent to the browser.