Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jade: How to include a javascript file

Tags:

express

pug

I need to include a javascript file to webpage. I write the following:

include /../scripts/jquery.timeago.js 

but I get

<script>/*  * timeago: a jQuery plugin, version: 0.8.2 (2010-02-16)  * @requires jQuery v1.2.3 or later  *  * Timeago is a jQuery plugin that makes it easy to support automatically  * updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago").  *  * For usage and examples, visit:  * http://timeago.yarp.com/  *  * Licensed under the MIT:  * http://www.opensource.org/licenses/mit-license.php  *  * Copyright (c) 2008-2010, Ryan McGeary (ryanonjavascript -[at]- mcgeary [*dot*] org)  */ (function($) { .... </script> 

as result. But I need:

<script src="/Scripts/jquery.timeago.js" type="text/javascript"></script> 

How to do it?

like image 847
Oleg Sh Avatar asked Jan 15 '13 23:01

Oleg Sh


People also ask

How do you include a JavaScript file?

To include an external JavaScript file, we can use the script tag with the attribute src . You've already used the src attribute when using images. The value for the src attribute should be the path to your JavaScript file. This script tag should be included between the <head> tags in your HTML document.

Where do I put JavaScript script files?

JavaScript in <head> or <body> You can place any number of scripts in an HTML document. Scripts can be placed in the <body> , or in the <head> section of an HTML page, or in both.


1 Answers

Put this in your jade file:

script(src="/Scripts/jquery.timeago.js")

like image 105
EhevuTov Avatar answered Sep 20 '22 03:09

EhevuTov