Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

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

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

random javascript showing up


Go to End


4 Posts   2117 Views

Avatar
Nicolaas

Forum Moderator, 224 Posts

5 June 2007 at 10:49am

Edited: 05/06/2007 10:54am

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

Avatar
Willr

Forum Moderator, 5523 Posts

5 June 2007 at 5:57pm

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.

Avatar
Ingo

Forum Moderator, 801 Posts

5 June 2007 at 7:47pm

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()

Avatar
Sam

Administrator, 690 Posts

6 June 2007 at 9:50am

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.