Experimental project

This is a sandbox project, which contains experimental code for developer use only.

JS path enhances any theme by allowing the front-end developer the opportunity to automatically include and cache javascript into pages and forms by js file naming conventions.

Example #1: If you desire to use jQuery (included in your theme) to add input tag events to a content type edit form with the <form id="post-node-form"> then you save your js file as "js/forms/post_node_form.js" within your current theme's folder.

Example #2: If you have multiple interactive articles posted under the relative URL "/articles/interactive" and you want to append a common JavaScript file to only the pages under that path, then you would save your js file as "js/paths/articles-interactive.js".

For example 2 it searches recursively from more to less specific and stops to inject the script once it finds a match (i.e. if your js file was named "js/paths/articles-interactive.js" then it would apply that first and never find "js/paths/articles.js"). This could change if other contributors have better suggestions. In the mean time, if you wanted to include articles.js INTO articles-interactive.js then you could use jQuery to load that script synchronously as a requirement of the articles-interactive.js file. An example of that would be:

jQuery.getScript("articles.js");

If you added that to the top of articles-interactives.js, it would load that script and any classes or functions and you could reference the classes or functions from the code in the articles-interactive.js file.

Note about js path theme inclusion

For many sites, some forms and pages are rendered using alternate themes from the primary theme. Be sure to place your js files into the correct <theme_folder>/js/paths and <theme_folder>/js/forms that presents the form or page. For example, if theme #1 presents site pages, but you are using a separate theme #2 for admin forms, you have to put your JS files into the admin theme #2 to affect your admin forms that use theme #2.

Project information