Selective Javascript Loader
Selective Javascript Loader is a WordPress plugin that automatically loads different Javascript files based on the blog section that is being viewed (index, category, single post, page).
It can be really useful if you make extensive use of Javascript in your theme and want to split the code and load functions only when you need them.
When activated, the plugin will do the following:
- On Index page: will try to load the index.js file
- On Single post: will try to load the single.js file
- On Category: will try to load the category-cat_slug.js file. If the file doesn’t exists it will try to load the category.js file.
- On Page: will try to load the page-page_slug.js file. If the file doesn’t exists it will try to load the page.js file.
Download
The plugin can be downloaded from the WordPress plugin directory.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Installation
When installing any new plugin it’s always a good idea to backup your blog data before installing.
- Upload the SelectiveJavascriptLoader folder to the
/wp-content/plugins/directory - Activate the plugin through the
Pluginsmenu in WordPress - Configure the plugin from the Settings page
Frequently Asked Questions
Where should I put Javascript files?
You must put Javascript file inside your theme folder. You can group your Javascript files in a folder inside your theme folder and specify its name using the plugin settings page.
My js files are not included in the page, why ?
Check the plugin settings page if js file loading is enabled. By default js loading is disabled.
What happens if I activate Javascript loading from the plugin settins
page and the .js file doesn’t exists?
Nothing :-) The plugin will not try to load a Javascript file if it doesn’t exists.
I’ve setup the plugin to include javascript files in footer, but nothing
happens
Check the footer.php file in your theme and make sure it calls the <?php
wp_footer(); ?> function.
Changelog
1.1
09/14/2009
- Added the option to choose if Javascript files should be included in the header or in the footer of the page. This option is available only if you are using WordPress 2.8 and above
- Added WordPress version checking.
- Corrected script inclusion for Wordpress 2.7
- Some code optimization
- Corrected a layout bug in the settings page
1.0
09/13/2009
First public release