Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Dynamically load javascript and CSS file based on URL

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 js
Octocat-spinner-32 .gitattributes
Octocat-spinner-32 .gitignore
Octocat-spinner-32 README.md
README.md

eRouter

Dynamically load JavaScript and CSS files based on URL

Example Usage:

eRouter(JSON Object - Required)

var RoutePath = {
    route:[
        // Blank path is loaded on EVERY page
        { path:"", js:["common.js", "jquery.js", "jquerymobile"], css:["router_common.css"] },
        // * are wildcards and will load for anything that match the pattern
        { path:"/*", js:["router_test.js"], css:["router_test.css"] },
        { path:"/articles/*/render.php", js:["router_test.js"], css:["router_test.css"] }
    ]
};

eRouter(RoutePath);

JSON Structure:

  • As you can see above the outer element must named 'route'.
  • Each of the child elements must have a 'path' attribute.
  • The 'js' and 'css' attributes are not required
  • The 'js' and 'css' may have an unlimited number of elements *(see 'Blank path is loaded on EVERY page' above)

Disclaimer

This code is provided without warranty. While I strive to maintain backwards compatibility with previous versions, the code is still under active development. As this is the case, some revisions may break compatibility with earlier versions of the library. Please keep this in mind when using eRouter.

Copyright and Licensing

Copyright (c) 2012 Ervin Kosch, released under the GPL 3 license

Something went wrong with that request. Please try again.