<?xml version="1.0" encoding="UTF-8"?><!-- generator="bbPress" -->

<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
>

<channel>
<title>ThemeShaper Forums Topic: Load javascript only on specific page</title>
<link>http://themeshaper.com/forums/</link>
<description>Help In Shaping WordPress Themes</description>
<language>en</language>
<pubDate>Fri, 24 May 2013 08:08:57 +0000</pubDate>

<item>
<title>Thompson on "Load javascript only on specific page"</title>
<link>http://themeshaper.com/forums/topic/load-javascript-only-on-specific-page#post-15219</link>
<pubDate>Mon, 30 Aug 2010 18:04:34 +0000</pubDate>
<dc:creator>Thompson</dc:creator>
<guid isPermaLink="false">15219@http://themeshaper.com/forums/</guid>
<description>&#60;p&#62;Whoa, I just found a really cool conditional tag in the codex, in case anyone is interested:&#60;/p&#62;
&#60;p&#62;comments_open()&#60;/p&#62;
&#60;p&#62;So you can actually set up WordPress to only load WordPress' commenting javascript if comments are open on a particular post or page. Now that is pretty cool. &#60;a href=&#34;http://codex.wordpress.org/Conditional_Tags#Any_Page_Containing_Posts&#34; rel=&#34;nofollow&#34;&#62;http://codex.wordpress.org/Conditional_Tags#Any_Page_Containing_Posts&#60;/a&#62;
&#60;/p&#62;</description>
</item>
<item>
<title>Thompson on "Load javascript only on specific page"</title>
<link>http://themeshaper.com/forums/topic/load-javascript-only-on-specific-page#post-15218</link>
<pubDate>Mon, 30 Aug 2010 17:41:44 +0000</pubDate>
<dc:creator>Thompson</dc:creator>
<guid isPermaLink="false">15218@http://themeshaper.com/forums/</guid>
<description>&#60;p&#62;Thank you tarpontech. template_redirect seems to work too. I saved that trick in case I need it in the future. It turns out that I think the problem with my code was that the if statement needs to be on the wp_register_script that specifies the URL of the new script. And since wp_enqueue_script can be in place of wp_register_script (at least from my reading), I ended up using just enqueue to try to keep it as short as possible. So this is what I ended up with:&#60;/p&#62;
&#60;p&#62;// Remove plugin JS and add my JS only where needed&#60;br /&#62;
		function childtheme_deregister_script() {&#60;br /&#62;
			wp_deregister_script( 'pluginJS' );&#60;br /&#62;
			if ( is_single('26') ) {&#60;br /&#62;
			wp_enqueue_script( 'pluginJS', (&#34;/wp-content/themes/thematic-child/form.js&#34;), false,'1.0');&#60;br /&#62;
			}&#60;br /&#62;
		}&#60;br /&#62;
		add_action( 'wp_print_scripts', 'childtheme_deregister_script', 100 );&#60;/p&#62;
&#60;p&#62;Thanks.
&#60;/p&#62;</description>
</item>
<item>
<title>tarpontech on "Load javascript only on specific page"</title>
<link>http://themeshaper.com/forums/topic/load-javascript-only-on-specific-page#post-15214</link>
<pubDate>Mon, 30 Aug 2010 16:12:53 +0000</pubDate>
<dc:creator>tarpontech</dc:creator>
<guid isPermaLink="false">15214@http://themeshaper.com/forums/</guid>
<description>&#60;p&#62;I'm not 100%, but I've seen a few times where if things don't fire on specified pages, it's (based on something I learned from Gene) because your script isn't being called early enough in Wordpress's order of operation.  Try swapping 'wp_print_scripts' with 'template_redirect'.&#60;br /&#62;
As this is the point when wordpress makes the decision as to what page to load, this may be the right place to stick a page-specific script like this.
&#60;/p&#62;</description>
</item>
<item>
<title>Thompson on "Load javascript only on specific page"</title>
<link>http://themeshaper.com/forums/topic/load-javascript-only-on-specific-page#post-15206</link>
<pubDate>Mon, 30 Aug 2010 05:32:23 +0000</pubDate>
<dc:creator>Thompson</dc:creator>
<guid isPermaLink="false">15206@http://themeshaper.com/forums/</guid>
<description>&#60;p&#62;Hi all,  Does anybody know how to load JS only on a specific page?&#60;/p&#62;
&#60;p&#62;		function childtheme_deregister_script() {&#60;br /&#62;
			wp_deregister_script( 'pluginJS' );&#60;br /&#62;
			wp_register_script( 'pluginJS', (&#34;http://www.domain.com/wp-content/themes/thematic-child/form.js&#34;), false);&#60;br /&#62;
			if ( is_home() ) {&#60;br /&#62;
                        wp_enqueue_script( 'pluginJS' );&#60;br /&#62;
                        }&#60;br /&#62;
		}&#60;br /&#62;
		add_action( 'wp_print_scripts', 'childtheme_deregister_script', 100 );&#60;/p&#62;
&#60;p&#62;This works to the extent that it removes the plugin's original javascript ('pluginJS') and instead loads mine from the URL. But it still does not load on only the specified pages. Any help please?
&#60;/p&#62;</description>
</item>

</channel>
</rss>
