I'd like to have offline the functionality of this javascript: jspretty. I know that I can get the same online, but I want it offline.
How can I run the js above?
I'd like to have offline the functionality of this javascript: jspretty. I know that I can get the same online, but I want it offline.
How can I run the js above?
Save the code in the link to a file with a js
extension. Example: jspretty.js
Place the .js
file in a folder on the local computer that is accessible over a local web server. i.e. usually in a folder like: c:\inetpub\wwwroot\
, c:\apache\htdocs\
, c:\xampp\htdocs\
, c:\wamp\www\
, /var/www/
etc. (These are only examples of some default web server paths and is ok for development environments IMO. But not recommended for production environments)
Refer to that local .js
file on a web page using absolute or relative paths.
Example:
<script src="http://localhost/folder/jspretty.js">
or
<script src="jspretty.js">
or
<script src="/folder/jspretty.js">
or
<script src="../jspretty.js">
or
<script src="../folder/jspretty.js">
For details on relative and absolute paths see:
file://path/to/the/file.js
. That said, unless there is a driver function, it won't do anything, so executing a javascript library isn't really helpful. you would have to create a stub/driver javascript that links to and calls functions within the library.file://
would work when referencing js files. I would put the code on a local web server and use a url to access the local js like:<script src="http://localhost/jspretty.js".
or access it using a relative path like:<script src="../jspretty.js">
or<script src="../somefolder/jspretty.js">