Comments (9)
You mean if you have html:
<link href="/css/styles.css" rel="stylesheet" type="text/css"/>
<script src="/js/script.js"></script>
it would turn into:
<style>
//styles.css content
</style>
<script>
//script.js content
</script>
The problem is how to identify those files, lets say you have:
<script src="http://example1.com/script.js"></script>
<script src="http://example2.com/js/script.js"></script>
<script src="script.js"></script>
<script src="../../script.js"></script>
Which parameters to pass to the compressor that would indicate which script to
replace with which file?
Original comment by [email protected]
on 10 Jul 2011 at 4:11
- Added labels: Type-Enhancement
- Removed labels: Type-Defect
from htmlcompressor.
Sorry, I haven't been clear; The files would passed to the compressor via
parameters like --external-js, --external-css.
Converting HTTP requests to inline JS/CSS is another concern.
Original comment by [email protected]
on 10 Jul 2011 at 5:37
from htmlcompressor.
But how to figure out which file to insert into which position? You can't just
provide a list of filenames as the same filename could mean different script
(as shown in the example above). It should be something like key value pairs:
"script.js" -> "c:/dir1/script.js"
"../../script.js" -> "c:/dir2/script.js"
Original comment by [email protected]
on 10 Jul 2011 at 5:50
from htmlcompressor.
Ah, no, actually the HTML file would *not* have links to the JS/CSS files like
<script src=script.js></script>. One would just specify the wanted files and
they would be injected in the <head> of the HTML.
Original comment by [email protected]
on 10 Jul 2011 at 5:58
from htmlcompressor.
Hm, I don't see a point then. What is the purpose of this feature? How are you
going to develop the page without css or js in it? Why would you want to insert
them only at the compression stage without even having control where on the
page they will be inserted (which is important)? Inserting javascript into
<head> should be your last option if you care about optimization.
I could understand replacing existing tags with inline content to save http
requests, but what you are describing looks like some very exotic task I am not
sure anyone else would ever use.
Original comment by [email protected]
on 10 Jul 2011 at 6:23
from htmlcompressor.
Yes, said like that... I guess that would just suit my specific need.
Although, following your method, one could pass each file to the script with
--external scripts.js=c:/dir1/script.js and so on. What do you think?
Original comment by [email protected]
on 10 Jul 2011 at 6:34
from htmlcompressor.
I will probably wait for more feedback to see if anyone else needs this feature
before implementing it.
Original comment by [email protected]
on 10 Jul 2011 at 9:23
from htmlcompressor.
[deleted comment]
from htmlcompressor.
Hi, I'd like to see this feature added to the taglib. It could work the way
"packtag" currently does... you specify a "src" attribute with either CSS or JS
URLs. These URLs can be both external and/or internal. For example,
<pack:script>
<src>/assets/javascripts/library/prototype/prototype.js</src>
<src>http://code.jquery.com/jquery-latest.js</src>
</pack:script>
<pack:style>
<src>/assets/stylesheets/common/normalize.css</src>
<src>/assets/javascripts/library/jquery/jquery-ui/css/smoothness/jquery-ui.css</
src>
</pack:style>
Original comment by [email protected]
on 2 Oct 2012 at 12:25
from htmlcompressor.
Related Issues (20)
- a
- preserve-line-breaks causes StackOverFlow when consumed 2000 empty lines. HOT 1
- Velocity Version
- compressor replaces double spaces in urls and thus brokes the links HOT 1
- http://compilehtml.com/ not working anymore HOT 2
- javaScript wan't be compressed
- How to use the htmlcompressor? HOT 1
- [deleted issue]
- Unable to use latest closure compiler HOT 3
- how can i did not reduce spaces when it is in the input tag HOT 1
- removeSpacesInsideTags incorrectly removes space after some unquoted attributes HOT 1
- Unable to use closure HOT 2
- Extend HTML compressor to compress and combine external files
- Google Closure Compiler compiler.jar not found even though present
- one-line comment HOT 1
- styleTypeAttrPattern should also search for type="text/css"
- Add a --preserve-single-line-break option
- Update for JSP 2.2 HOT 2
- greedy simple attributes remove content for all attributes ending in "disabled" such as ng-disabled
- && in attributes breaks compression HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from htmlcompressor.