What file extensions are used most commonly by different languages? Please don't put source file names (like .java) but rather extensions that would be present in a URL for rendered pages.
Here is my (alphabetized) list so far
ASP Classic
asp
ASP.NET
aspx
axd
asx
asmx
ashx
CSS
css
Coldfusion
cfm
Erlang
yaws
Flash
swf
HTML
html
htm
xhtml
jhtml
Java
jsp
jspx
wss
do
action
JavaScript
js
Perl
pl
PHP
php
php4
php3
phtml
Python
py
Ruby
rb
rhtml
SSI
shtml
TS
XML
xml
rss
svg
Other (C, perl etc.)
cgi
dll
Any more? I'll keep updating this based on comments. Largest correct additions (or deletions) is the accepted answer.
Aside: This is for comparing language use online: http://blog.paulisageek.com/2009/10/file-extensions-on-internet.html
Keep in mind that good URL design will completely hide any underlying file types.
I have created a Github gist that contains a list of programming languages and their extensions, here is a subset of the data included in the gist file:
{
"name":"CoffeeScript",
"type":"programming",
"extensions":[
".coffee",
"._coffee",
".cake",
".cjsx",
".cson",
".iced"
]
},{
"name":"ColdFusion",
"type":"programming",
"extensions":[
".cfm",
".cfml"
]}
I hope it is helpful.
languages.json.
.action — struts2
.do — struts1
.xml — XML
.rss — RSS feeds
.atom — Atom feeds(RSS)
(no extension) -- used now a days to increase readability of the URL, check stackoverflow URL
Ruby also tended to use .rhtml in the past.
Stellent uses the .hcsp extension for its page templates.
I believe Django uses .dtl.
.yaws (Erlang Yaws Web Server)
Here is an extension you forgot:
.adp — AOLServer using TCL
Ruby on Rails also uses the following internally for templates (files that are mostly HTML or JavaScript). So they're not really public facing, and are transparent to the end user/robot.
.html.erb
.erb
.rjs
Used to be that most CGI scripts were written in Perl.
IE specific strangeness:
.hta — html application
.htc — html components, allows you to alter IE behavior at runtime, from you website!
Also XML:
.svg — it's not just an image format!
.js, .html, .htm, .xhtml probably deserve a nod.
-SSI (Server Side Includes), use the extension .shtml
Add there:
ASP.NET
.axd
.asx
.asmx
.ashx
.aspx
.aspx
.asp
.css
REBOL tends to use .r
But .cgi is also used by some for REBOL CGI scripts.
ASP.NET needs a couple more, but I'm not sure this is exhaustive:
aspx
ascx
asmx (web services)
Here's a few of the commonly-used (but rarely enforced) extensions for some CSS dialects:
.hss for hss style sheets
.sass for sass style sheets
.less for less css style sheets
.ccss or .pcss for clever css style sheets
Going old school: .cgi
Typically written in C or Perl
.java .cs and .i_am_kidding_i_read_the_question.
On the serious side, swf (Flash) get hidden by the JS that loads them, generally, but they are extensions usually seen by the client. This is a limit case because it's not like JPEG (doesn't allow for web programming) nor like Javascript. But then, neither is PHP/ASP/JSP because from the client side it's just markup :)
.cs ----> C#
.kt ----> Kotlin
.json has become popular as a data xfer format
.png .jpg .gif are the most common graphics, but there are others.
Also video extensions
Related
is there any option to work in mako templates (based on HTML it is something like Flask but very old) and use all extensions from HTML? I installed mako templates extension but that is just for a syntax highlighting.
I used to work in Atom and there was a extension which uses both of languages.
For examaple: see hints while writting bootstrap classes col-something etc.
So far Iam using this:
"emmet.includeLanguages": {
"mako": "html"
}
I can use Emmet Abbrevation but that is all.
Thanks for any help.
Adding a file extension to a language
You can add new file extensions to an existing language with the files.associations setting.
For example, the setting below adds the .myphp file extension to the php language identifier:
"files.associations": {
"*.myphp": "php"
}
See more: https://code.visualstudio.com/docs/languages/overview
First time making a webpage in html. I have an assignment to format a bunch of text using appropriate html tags. No problem. But I would like to clean up my code by storing the paragraphs in a separate file. I have been searching for hours and cannot find anything.
Bottom line what I want to do:
have a file: strings.{html/xml/php/js}
and access variables from that file in my page index.html doing something like this:
<p>$someVarName</p>
This seems like a bit of a strange 'optimization', one that is not usually made, at least as far as I understand the question.
What you can do is have a JavaScript file e.g. script.js, and reference it in your index.html file:
<script language="javascript" type="text/javascript" src="script.js"></script>
In script.js you can insert custom HTML as such:
document.getElementById('tag-id').innerHTML = '<p>some text</p>';
To reduce the page load time of a website in the browser usually one tries to deliver one HTML file per page and one compact CSS/JS/image/SVG file for the whole website. All files are usually aggregated server side from multiple resources as you like to do.
Here are some common ways to enrich HTML pages and their creation process:
Using an iframe you can let the browser import and display another page using a single HTML tag but this is not recommended because it complicates layouting and a content's URL is not visible to the user in the browser's address bar.
Using PHP you could have an index.php with the contents of your index.html plus some PHP snippets printing variables from an included variables.php. PHP requires server side execution which is typically implemented using Apache2 webserver. A PHP script, index.php, would be executed each request / each time a user accesses the page.
index.php
<html>
<?php require_once 'variables.php'; ?>
...
<?php print $property1; ?>
<?php print $property2; ?>
</html>
variables.php
<?php
$property1 = 'value 1';
$property2 = 'value 2';
?>
Using XSLT you can transform the HTML as XML. This requires the HTML formatted as well-formed XML. XSLT can be executed both client and server side. XSLT 1 is limited but supported by major modern browsers. XSLT 2 is not supported by most browsers but often executed on the server side or rather offline to generate aggregated static html pages from XML/HTML with e.g. Saxon CE. On the downside XSLT may be more difficult to start with than PHP.
Using JavaScript (JS) you can also let the browser load additional documents into a currently displayed document. This is also known as AJAX and can be done with e.g. jQuery or AngularJS. With JS you can create interactive web pages and most modern websites make use of it.
BUT: Loading contents with JS on the client side limits the ability of search engines to index your content (bots usually do not execute JS). You should only use this method if your contents should not be crawled by bots or if you provide an alternative.
Of course, there is also a plethora of other template/programming languages that offer server side solutions for your problem like Java, Python and Ruby and their specialized frameworks.
Additionally you should check out one of the many existing PHP CMS (server side HTML page generator with UI to edit content).
I have a portal that is under a virtual host in Apache. All lot of its .css and .js is generated dynamically by the underlying tomcat web application. What I want to do is inject some of my own .css and .js into the mix before it is served. I think I need something like mod_rewrite but for html.
I know I could try to piggyback onto some resource reference that is used on every page and use mod_rewrite that way, but that is hard to do and I need my css to be applied last.
Tell me there are some magic beans for this. I just need to inject a couple scripts and styles right at </head>.
I haven't used it before, but it looks like mod_ext_filter could do this
By looking at the example, you could try the following Perl script
#!/usr/local/bin/perl -w
use strict;
my $extraCode = "<script src=\"http:/...\"></script>";
while (<STDIN>) {
s/<\/head>/$extraCode<\/head>/i;
print;
}
After I posted this, I noticed someone recommended https://serverfault.com/questions/46449/how-to-inject-html-code-into-every-delivered-html-page. mod_proxy_html and mod_sed looks good
This would be an HTML minifier that skips everything between <% and %>.
Actually, an Open Source HTML minifier would be a good starting place, especially if it already had code to preserve the contents certain blocks like <textarea. It's code might be able to be made to preserve <%%> blocks also.
I am aware that HTML minifiers are less common because that changes more often than JS/CSS and is often dynamically generated, but if the JSP compiler could be made to minify before making its compiled cache copy, it would result in minified HTML.
Also, an ASP minifier would probably be very close to the same thing. And I don't care about custom tags that have meaning to the server. The only stuff that matters to the server (for my company) is in the <%%> blocks.
This question is a bit outdated but an answer with a resource still hasn't made it's way to the posting.
HtmlCompressor makes this very thing possible and quite simply.
You can use it via Java API:
String html = getHtml(); //your external method to get html from memory, file, url etc.
HtmlCompressor compressor = new HtmlCompressor();
String compressedHtml = compressor.compress(html);
Or you can use it via Taglib:
Download .jar file of the current release and put it into your lib/ directory
Add the following taglib directive to your JSP pages:
<%# taglib uri="http://htmlcompressor.googlecode.com/taglib/compressor" prefix="compress" %>
Please note that JSP 2.0 or above is required.
In JSP:
<compress:html removeIntertagSpaces="true">
<!DOCTYPE html>
...
</html>
</compress:html>
Cheers
JSP is transformed to Java code and subsequntly compiled to bytecode. Minifying JSP has no purpose then.
You can process output generated by JSP page by writing custom filter. I have written filter to trim empty lines and unnecessary whitespace from JSP output, unfortunately it's not public. But if you google around, I'm sure you can find servlet filters to remove unneeded stuff from generated HTML.
Have a look at the Trim Filter (http://www.servletsuite.com/servlets/trimflt.htm), which you can simply map in your web.xml.
It will help you to remove whitespace, and can also strip off comments.
From my experience, whitespace occurs a lot in JSPs if you use tags that themselves don't have any output, such a the JSTL C control tags (c:if, c:choose, ...), and then this comes in very handy.
As you are already aware that HTML minification is less common and it also results in errors sometime than getting any benefit out of it. HTML is also dynamically generated content.
On the other hand, there are many better ways to speed up the application front end.
Minimizing HTTP requests
Minifying JS, CSS contents
gzip/deflate contents
Leveraging browser cache
Server Side caching, until resource changes
And many other - http://developer.yahoo.com/performance/rules.html
WebUtilities is a small java library to help speed up J2EE webapp front-end. Below is the link.
http://code.google.com/p/webutilities/
With new 0.0.4 version it does many optimization and results in significant performance boost. Please have a look in case you find it useful.
Is there an equivalent of Google's Closure Compiler for HTML minimizing?
I presume you mean the Closure compiler, which effectively compresses javascript. If you search the goog for "HTML Compressor", you will find a lot of options catering to individual needs.
Consider HTML Tidy:
http://infohound.net/tidy/
It's a free tool that does a great job.
I think you can try google's mod_pagespeed, which will minify the response content.
I write a python script, replace all id and class name at pushlish. The script generate unique token for each class name and id, relpace the in both javascript,css and html template file. It workds greate for me
I am using Minify to trim and compress the html at runtime. The only requirements and setup are that you put Minify on your server and prepend the following code to the page.
<?php require $_SERVER['DOCUMENT_ROOT'] . '/min/pageBuffer.php'; ?>
<!-- html -->