Derby offers the Script:
tag:
<Scripts:>
<script type="text/javascript" src="/components/jquery/jquery.js"></script>
The components directory is because of the usage of bower. Put the components
directory into the public
directory. According to the express FAQ, the static routes search below the given directory (which is public in derby's example application). Configure bower to put the files under public/components
(Choose bower install directory).
The public directory is configured at lib/server/index.js
: .use(gzippo.staticGzip(publicPath, {maxAge: ONE_YEAR}))
, where publicPath
is configured above to path.join(root, 'public')
.
Be aware that the "idea behind the inline script is that it runs immediately, before any of the external scripts are loaded. This should only be used in rare cases where the script should run before the page is displayed in the browser, such as sizing something to the window or autofuocusing an element in browsers that don't support the "autofocus" attribute." Nate Smith in the derby google group.
Inline scripts should be placed in inline.js
, located in the same directory as the application's index.js
.
If you require jQuery to do something on the loaded page, following code snipped worked at my side (Firefox, Chrome) in inline.js
:
window.onload = function() {
alert($(this));
}