Raw CSS / javascript supply on request

Minimizing style sheets and script files improves the performance of your site.

However, sometimes you may want to make non-minified versions of files available - perhaps to comply with the GPL or to implement an optional REST restriction on demand.

Is there a standardized way to do this? The only way I can think of is to use a naming convention:

http://example.com/css/styles.min.css - short version

http://example.com/css/styles.css - unlimited version

The problem with this approach is that it relies on an out-of-band agreement. Is there a more stringent way to implement non-minified code on demand?

+4
source share
2 answers

You may have some form of a handler (for example, a .NET handler) for .css files, which is used by default for the mini version, but if some parameter was found in querystring (for example debug = true) (for example, debug = true), run an unlimited version.

Thus, you can always refer to the .css version, and if there is a mini-version available that can be used in preference.

+4
source

Suggestion: Use Hypermedia. Advantage: your choice of URI does not matter.

If you provide sources in a visible way to your end user during the normal use of your web application:

 <a target="_blank" href="http://www.example.com/css/styles.css" rel="sourcecode" title="The non-minified CSS source."> Click here for CSS source code. </a> <a target="_blank" href="http://www.example.com/scripts/buttons.js" rel="sourcecode" title="The non-minified JavaScript source."> Click here for JavaScript source code. </a> 

If you provide sources for developer users outside of their normal use of the web application, it might make sense to link to them in an invisible section of the source:

 <link rel="sourcecode" type="text/css" href="http://www.example.com/css/styles.css" title="The non-minified CSS source." /> <link rel="sourcecode" type="text/javascript" href="http://www.example.com/scripts/buttons.js" title="The non-minified JavaScript source." /> 

These links will only be available to developers who are considering the HTML source, or to people who have really tricked user agents.

On the same lines, you can put the source without restrictions (but not JS) as an alternative stylesheet.

Note: rel="sourcecode" not a standard (I just finished), but I am sure that it does not violate the specification; and along with the title it helps communicate the purpose of the link.

+2
source

All Articles