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

Disableing javaScript Libraries?


Go to End


6 Posts   2733 Views

Avatar
MKayHavoc

Community Member, 33 Posts

24 July 2008 at 7:49pm

How can I disable the the following javaScript libraries:

<script type="text/javascript" src="jsparty/loader.js"></script>
<script type="text/javascript" src="jsparty/prototype.js"></script>
<script type="text/javascript" src="jsparty/behaviour.js"></script>
<script type="text/javascript" src="jsparty/prototype_improvements.js"></script>
<script type="text/javascript" src="jsparty/tabstrip/tabstrip.js"></script>
<script type="text/javascript" src="jsparty/scriptaculous/effects.js"></script>

In my site, but obviously leave them for the CMS backend?

Cheers

Avatar
Willr

Forum Moderator, 5523 Posts

24 July 2008 at 10:15pm

You need to use a method called Requirements::block(the file name);. You would put this in your in the init() function Page_Controller class in Page.php.

So you would need

Requirements::block("jsparty/loader.js");
..

for each JS file you want to block on the front end.

Avatar
kudesign

Community Member, 64 Posts

6 December 2008 at 11:54pm

Edited: 06/12/2008 11:59pm

Hi, so if I want to add a js, or a new css to load, do I just add in a requirement?

I want to load

slider.css
and
slider.js

e.g.

Requirements::themedCSS("slider");
Requirements::("jsparty/slider.js");

Avatar
kudesign

Community Member, 64 Posts

6 December 2008 at 11:57pm

Edited: 06/12/2008 11:59pm

This is what my page.php looks like at the moment

<?php

class Page extends SiteTree {
	static $db = array(
	);
	static $has_one = array(
   );
}

class Page_Controller extends ContentController {
	function init() {
		parent::init();
		
		Requirements::themedCSS("layout");
		Requirements::themedCSS("typography");
		Requirements::themedCSS("form");
	}
}

?>

So can I add to the list

Requirements::themedCSS("slider");
Requirements::("jsparty/slider.js"); 

thanks!

Avatar
Willr

Forum Moderator, 5523 Posts

7 December 2008 at 12:11am

The best way to to keep your own JS in themes/yourthemename/javascript. And you would include it like

Requirements::javascript("themes/yourthemename/javascript/slider.js");

in the function init() just like the rest of the Requirements

Avatar
kudesign

Community Member, 64 Posts

7 December 2008 at 12:26am

Thanks for the quick reply! this helps. I tried coding it into the template, and it also works, but I think coding it in page.php sounds like a better way to do it.

Another quick question, any idea why my log-in page login name/openID tabs doesn't hide in Firefox anymore?

http://www.kudesign.co.nz/studio/Security/login

I looked at the tabstrip.js, and tabstrip.css, they seem to be working fine... just won't hide in Firefox. Any tip will be much appreciated!!