Login | Forgot password | Register

X

What is OpenID?

OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.

With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.

For more information visit the official OpenID site.

Jump to:

1598 Posts in 399 Topics by 403 members

Template Questions

SilverStripe Forums » Template Questions » [SOLVED] Why does calling Requirements::javascript include other core javascript files?

Page: 1
Go to End
Author Topic: [SOLVED] Why does calling Requirements::javascript include other core javascript files? 766 Views
  • Ryno in Stereo
    avatar
    Community Member
    8 posts

    [SOLVED] Why does calling Requirements::javascript include other core javascript files? Link to this post

    Environment: Windows XP SP3 XAMPP, PHP 5.2.8, Apache 2.2.11
    SilverStripe version: /branches/2.3

    In my customised version of mysite/code/Page.php in the init() method, whenever I make a call to Requirements::javascript, the following always end up being included in the outputted HTML.

    <script type="text/javascript" src="http://development.surferscentury.com.au/jsparty/behaviour.js?m=1231497686"></script>
    <script type="text/javascript" src="http://development.surferscentury.com.au/jsparty/prototype.js?m=1231381869"></script>
    <script type="text/javascript" src="http://development.surferscentury.com.au/sapphire/javascript/i18n.js?m=1231381787"></script>
    <script type="text/javascript" src="http://development.surferscentury.com.au/sapphire/javascript/lang/en_US.js?m=1231381787"></script>
    <script type="text/javascript" src="http://development.surferscentury.com.au/themes/surferscentury/js/jquery-1.3.1.min.js?m=1232688508"></script><script type="text/javascript" src="http://development.surferscentury.com.au/themes/surferscentury/js/swfobject.js?m=1232617897"></script><script type="text/javascript" src="http://development.surferscentury.com.au/jsparty/behaviour.js?m=1231497686"></script><script type="text/javascript" src="http://development.surferscentury.com.au/jsparty/prototype.js?m=1231381869"></script><script type="text/javascript" src="http://development.surferscentury.com.au/sapphire/javascript/i18n.js?m=1231381787"></script><script type="text/javascript" src="http://development.surferscentury.com.au/sapphire/javascript/lang/en_US.js?m=1231381787"></script><script type="text/javascript">//<![CDATA[
                Behaviour.register({
                   '#switchView a' : {
                      onclick : function() {
                         var w = window.open(this.href,windowName(this.target));
                         w.focus();
                         return false;
                      }
                   }
                });

                function windowName(suffix) {
                   var base = document.getElementsByTagName('base')[0].href.replace('http://','').replace(/\//g,'_').replace(/\./g,'_');
                   return base + suffix;
                }
                window.name = windowName('site');

    //]]></script>

    Why is this?

    Calling Requirements::clear() doesn't work because as soon as I include any javascript via the Requirements:javascript() method, I cannot stop the above output?

    How can I stop this happening as I want control over what JavaScript files do and do not display.

  • Nivanka
    avatar
    Community Member
    337 posts

    Re: Why does calling Requirements::javascript include other core javascript files? Link to this post

    Do you mean that the <script></script> tags are visible on the screen?

    Check whether they are in side the <head></head> section

  • ajshort
    avatar
    Community Member
    170 posts

    Re: Why does calling Requirements::javascript include other core javascript files? Link to this post

    Nivanka - I think you misunderstood the question.

    Ryno: These JS files are included in order to enable javascript translation. However, if you don't need any of this, you can manually block each javascript file in your Page_Controller->init() method. Just add something like this to block a javascript file:

    Requirements::block('jsparty/behaviour.js');

    and so on for each file you don't need.

  • Ryno in Stereo
    avatar
    Community Member
    8 posts

    Re: Why does calling Requirements::javascript include other core javascript files? Link to this post

    Thanks ajshort, that's exactly what I needed to know!

  • Nivanka
    avatar
    Community Member
    337 posts

    Re: [SOLVED] Why does calling Requirements::javascript include other core javascript files? Link to this post

    Ah yes Ajshort, I thought something else.

  • Hamish
    avatar
    Community Member
    609 posts

    Re: [SOLVED] Why does calling Requirements::javascript include other core javascript files? Link to this post

    I posted on the developer forum about this - I'm not a fan. Even if there is no translatable content on the page, prototype and i18n are included. We should not have to explicitly block javascript files from loading if we're not using them.

    It also adds another upgrade step, more baggage to the root page type and so on.

    Hamish

  • Ingo
    avatar
    Administrator
    596 posts
    766 Views
Page: 1
Go to Top

Currently Online: Dramew, silk

Welcome to our latest member: holy noli

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.