Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » random javascript showing up

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 1547 Views
  • Nicolaas
    Avatar
    Forum Moderator
    213 Posts

    random javascript showing up Link to this post

    Hi Folk

    I have the following random Javascript lines showing up in my page code:

    <script type="text/javascript" src="jsparty/behaviour.js"></script>
    <script type="text/javascript" src="jsparty/prototype.js"></script>
    <script type="text/javascript" src="jsparty/scriptaculous/effects.js"></script>
    <script type="text/javascript" src="cms/javascript/PageCommentInterface.js"></script>

    Where do these lines come from? I dont really need all that Javascript. I never asked them to be there.... Furthermore, if they need to be there, then I would at least have the opportunity to move them up so that my own JS can come afterwards...

    Any hints greatly appreciated.

    Thank you

    Nicolaas

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: random javascript showing up Link to this post

    Im taking a guess but I would think those js's are for the commenting system (eg leaving a comment on a page if you enable that). you probably dont want to be playing around with them if you need the commenting feature.

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: random javascript showing up Link to this post

    exactly. as soon as you include $PageComments somewhere in your template, the PageCommentInterface is automatically loaded, which requires these javascript-files.
    see cms/code/sitefeatures/PageCommentInterface.php->PostCommentForm()

  • Sam
    Avatar
    Administrator
    679 Posts

    Re: random javascript showing up Link to this post

    The Requirements class is what facilitates this.

    You can call this in your controller's init() method, or anywhere else in your code:
    Requirements::javascript('mysite/javascript/some-file.js');

    It will then be added to a list of include tags that are inserted just before the </head> tag.

    We do this so that any piece of PHP code can demand that a particular javascript / css file be included. For example, if you make use a TreeMultiselectField, it will include the javascript required to support this.

    1547 Views
Page: 1
Go to Top

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

Comments on this website? Please give feedback.